refactor: shorten model and table prefixes

This commit is contained in:
2026-07-23 14:30:17 +08:00
parent 6e7be2f3a4
commit 0ca2898ac0
71 changed files with 707 additions and 638 deletions

View File

@@ -23,28 +23,32 @@ func New(dsn string) error {
}
func AutoMigrate(database *gorm.DB) error {
if err := database.AutoMigrate(
&SenlinAgentSchemaMigration{},
&SenlinAgentUser{},
&SenlinAgentProject{},
&SenlinAgentInboxItem{},
&SenlinAgentInboxSuggestion{},
&SenlinAgentTask{},
&SenlinAgentNote{},
&SenlinAgentSource{},
&SenlinAgentAIExpertCategory{},
&SenlinAgentAIExpertItem{},
&SenlinAgentAISession{},
&SenlinAgentTag{},
&SenlinAgentProjectChannel{},
&SenlinAgentCronPlan{},
&SenlinAgentProjectEvent{},
&SenlinAgentAIKey{},
&SenlinAgentAICallLog{},
&SenlinAgentAIRateBucket{},
&SenlinAgentTaskShare{},
cleanDatabase := database.Session(&gorm.Session{NewDB: true})
if err := cleanDatabase.Transaction(renameLegacyTables); err != nil {
return err
}
if err := cleanDatabase.AutoMigrate(
&SaSchemaMigration{},
&SaUser{},
&SaProject{},
&SaInboxItem{},
&SaInboxSuggestion{},
&SaTask{},
&SaNote{},
&SaSource{},
&SaAIExpertCategory{},
&SaAIExpertItem{},
&SaAISession{},
&SaTag{},
&SaProjectChannel{},
&SaCronPlan{},
&SaProjectEvent{},
&SaAIKey{},
&SaAICallLog{},
&SaAIRateBucket{},
&SaTaskShare{},
); err != nil {
return err
}
return runVersionedMigrations(database)
return runVersionedMigrations(cleanDatabase)
}