feat: 接入商务用户资料和全局统计偏好
This commit is contained in:
@@ -30,9 +30,25 @@ func Migrations() []migration.Step {
|
||||
},
|
||||
{ID: "202608210002_communication_surface", Migrate: ensureCommunicationSurface},
|
||||
{ID: "202608210003_communication_test_surface", Migrate: ensureCommunicationTestSurface},
|
||||
{ID: "202611030002_business_user_fields", Migrate: ensureBusinessUserFields},
|
||||
}
|
||||
}
|
||||
|
||||
func ensureBusinessUserFields(db *gorm.DB) error {
|
||||
// 与已交付迁移 SQL 的字段保持一致,仅补缺列,保留导入值和密码。
|
||||
for _, field := range []string{"Level", "ParentID", "IDPath", "RealName", "QQNumber", "BusinessStatus", "RejectReason"} {
|
||||
if !db.Migrator().HasColumn(&userPO{}, field) {
|
||||
if err := db.Migrator().AddColumn(&userPO{}, field); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !db.Migrator().HasIndex(&userPO{}, "idx_sys_users_business_parent") {
|
||||
return db.Migrator().CreateIndex(&userPO{}, "idx_sys_users_business_parent")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Kept as a migration version for existing installations; the canonical
|
||||
// communication surface seeder is idempotent and now owns the test endpoint.
|
||||
func ensureCommunicationTestSurface(db *gorm.DB) error { return ensureCommunicationSurface(db) }
|
||||
|
||||
Reference in New Issue
Block a user