forked from baron/baron-sso
사용자 테넌트 소속 데이터 정리
This commit is contained in:
@@ -139,7 +139,6 @@ func buildSuperAdminBrokerUser(email, name string) *domain.BrokerUser {
|
||||
Attributes: map[string]interface{}{
|
||||
"department": "Admin",
|
||||
"affiliationType": "internal",
|
||||
"companyCode": "",
|
||||
"grade": "",
|
||||
"role": domain.RoleSuperAdmin,
|
||||
},
|
||||
|
||||
@@ -37,6 +37,9 @@ func migrateSchemas(db *gorm.DB) error {
|
||||
if err := dropLegacyTenantDomainUniqueIndex(db); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := dropLegacyUserCompanyColumns(db); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Add all domain models here
|
||||
return db.AutoMigrate(
|
||||
@@ -61,6 +64,21 @@ func migrateSchemas(db *gorm.DB) error {
|
||||
)
|
||||
}
|
||||
|
||||
func dropLegacyUserCompanyColumns(db *gorm.DB) error {
|
||||
if !db.Migrator().HasTable(&domain.User{}) {
|
||||
return nil
|
||||
}
|
||||
for _, column := range []string{"company_code", "company_codes"} {
|
||||
if !db.Migrator().HasColumn(&domain.User{}, column) {
|
||||
continue
|
||||
}
|
||||
if err := db.Migrator().DropColumn(&domain.User{}, column); err != nil {
|
||||
return fmt.Errorf("failed to drop legacy users.%s column: %w", column, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func dropLegacyTenantDomainUniqueIndex(db *gorm.DB) error {
|
||||
if !db.Migrator().HasTable(&domain.TenantDomain{}) {
|
||||
return nil
|
||||
|
||||
@@ -34,7 +34,6 @@ func SeedAdminIdentity(idp domain.IdentityProvider) (string, error) {
|
||||
Attributes: map[string]interface{}{
|
||||
"department": "Admin",
|
||||
"affiliationType": "internal",
|
||||
"companyCode": "",
|
||||
"grade": "",
|
||||
"role": "super_admin", // Explicitly set role for Kratos traits
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user