chore: simplify db schema creation (#26693)
This commit is contained in:
parent
ad014333b2
commit
45741b1c90
11 changed files with 35 additions and 47 deletions
|
|
@ -13,17 +13,15 @@ type DB struct {
|
|||
name string
|
||||
}
|
||||
|
||||
var (
|
||||
sessions Sessions
|
||||
)
|
||||
var sessions Sessions
|
||||
|
||||
func init() {
|
||||
db.Register(func() error {
|
||||
if err := db.Instance.AutoMigrate(new(Session)); err != nil {
|
||||
db.Register(func(db *gorm.DB) error {
|
||||
if err := db.AutoMigrate(new(Session)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return db.Instance.Find(&sessions).Error
|
||||
return db.Find(&sessions).Error
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue