mirror of
https://github.com/muety/wakapi.git
synced 2025-12-05 22:20:24 -08:00
34 lines
550 B
Go
34 lines
550 B
Go
package migrations
|
|
|
|
import (
|
|
"github.com/muety/wakapi/config"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func init() {
|
|
const name = "20210213-add_has_data_field"
|
|
f := migrationFunc{
|
|
name: name,
|
|
f: func(db *gorm.DB, cfg *config.Config) error {
|
|
if hasRun(name, db) {
|
|
return nil
|
|
}
|
|
|
|
statement := "UPDATE users SET has_data = TRUE"
|
|
|
|
if cfg.Db.IsMssql() {
|
|
statement = "UPDATE users SET has_data = 1"
|
|
}
|
|
|
|
if err := db.Exec(statement).Error; err != nil {
|
|
return err
|
|
}
|
|
|
|
setHasRun(name, db)
|
|
return nil
|
|
},
|
|
}
|
|
|
|
registerPostMigration(f)
|
|
}
|