refactor: shorten model and table prefixes
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user