Database cleaner

This commit is contained in:
2024-04-06 14:05:51 +08:00
parent f2f75269d5
commit b2719ae302
3 changed files with 51 additions and 7 deletions

View File

@ -5,14 +5,16 @@ import (
"gorm.io/gorm"
)
var DatabaseAutoActionRange = []any{
&models.Account{},
&models.Channel{},
&models.ChannelMember{},
&models.Message{},
&models.Attachment{},
}
func RunMigration(source *gorm.DB) error {
if err := source.AutoMigrate(
&models.Account{},
&models.Channel{},
&models.ChannelMember{},
&models.Message{},
&models.Attachment{},
); err != nil {
if err := source.AutoMigrate(DatabaseAutoActionRange...); err != nil {
return err
}