Interactive/pkg/database/migrator.go

32 lines
547 B
Go
Raw Normal View History

2024-02-01 15:26:17 +00:00
package database
import (
2024-03-20 12:57:21 +00:00
"git.solsynth.dev/hydrogen/interactive/pkg/models"
2024-02-01 15:26:17 +00:00
"gorm.io/gorm"
)
2024-04-06 03:47:58 +00:00
var DatabaseAutoActionRange = []any{
&models.Account{},
&models.Realm{},
&models.RealmMember{},
&models.Category{},
&models.Tag{},
&models.Moment{},
&models.Article{},
&models.Comment{},
&models.Reaction{},
&models.Attachment{},
}
2024-02-01 15:26:17 +00:00
func RunMigration(source *gorm.DB) error {
if err := source.AutoMigrate(
2024-04-06 03:47:58 +00:00
append([]any{
&models.AccountMembership{},
}, DatabaseAutoActionRange...)...,
2024-02-01 15:26:17 +00:00
); err != nil {
return err
}
return nil
}