refactor(db): use version string as primary key for ConfigVersion

-transition `of_config_versions` primary key from `id` to `version` string.
-add database migration files `202606270001_make_version_primary_key.sql` for PostgreSQL and SQLite.
-introduce AfterFind/AfterCreate GORM hooks to preserve JSON backward compatibility.
-refactor API controllers, logics, and front-end typescript definitions to receive `string` parameter.
This commit is contained in:
ryan
2026-06-27 13:38:02 +08:00
parent 13d6966cb5
commit ac7b776378
8 changed files with 11 additions and 87 deletions
@@ -20,19 +20,6 @@ import (
"gorm.io/gorm"
)
type configVersionRecord struct {
ID uint `gorm:"primaryKey"`
Version string `gorm:"column:version"`
SnapshotJSON string `gorm:"column:snapshot_json"`
SupportFilesJSON string `gorm:"column:support_files_json"`
Checksum string `gorm:"column:checksum"`
IsActive bool `gorm:"column:is_active"`
}
func (configVersionRecord) TableName() string {
return "of_config_versions"
}
func setupProtocolTestEnv(t *testing.T) (*gin.Engine, func()) {
t.Helper()
@@ -46,7 +33,7 @@ func setupProtocolTestEnv(t *testing.T) (*gin.Engine, func()) {
&model.OpenFlareApplyLog{},
&model.OpenFlareNodeSystemProfile{},
&model.OpenFlareHealthEvent{},
&configVersionRecord{},
&model.ConfigVersion{},
))
db.SetDB(sqliteDB)