🐛 fix(db): rename composite unique indexes to avoid drop/recreate on restart
- Model: rename `uk_model_name` -> `uk_model_name_delete_at` (composite on `model_name` + `deleted_at`) - Vendor: rename `uk_vendor_name` -> `uk_vendor_name_delete_at` (composite on `name` + `deleted_at`) - Keep legacy cleanup in `model/main.go` to drop old index names (`uk_model_name`, `model_name`, `uk_vendor_name`, `name`) for compatibility. Result: idempotent GORM migrations and no unnecessary index churn on MySQL restarts. Files: - `model/model_meta.go` - `model/vendor_meta.go`
This commit is contained in:
+2
-2
@@ -21,7 +21,7 @@ type BoundChannel struct {
|
||||
|
||||
type Model struct {
|
||||
Id int `json:"id"`
|
||||
ModelName string `json:"model_name" gorm:"size:128;not null;uniqueIndex:uk_model_name,priority:1"`
|
||||
ModelName string `json:"model_name" gorm:"size:128;not null;uniqueIndex:uk_model_name_delete_at,priority:1"`
|
||||
Description string `json:"description,omitempty" gorm:"type:text"`
|
||||
Icon string `json:"icon,omitempty" gorm:"type:varchar(128)"`
|
||||
Tags string `json:"tags,omitempty" gorm:"type:varchar(255)"`
|
||||
@@ -30,7 +30,7 @@ type Model struct {
|
||||
Status int `json:"status" gorm:"default:1"`
|
||||
CreatedTime int64 `json:"created_time" gorm:"bigint"`
|
||||
UpdatedTime int64 `json:"updated_time" gorm:"bigint"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index;uniqueIndex:uk_model_name,priority:2"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index;uniqueIndex:uk_model_name_delete_at,priority:2"`
|
||||
|
||||
BoundChannels []BoundChannel `json:"bound_channels,omitempty" gorm:"-"`
|
||||
EnableGroups []string `json:"enable_groups,omitempty" gorm:"-"`
|
||||
|
||||
Reference in New Issue
Block a user