1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00
wakapi/migrations/20210221_add_created_date_column.go

28 lines
467 B
Go
Raw Normal View History

2021-02-21 14:02:19 +03:00
package migrations
import (
"github.com/muety/wakapi/config"
"gorm.io/gorm"
)
func init() {
const name = "20210221-add_created_date_column"
f := migrationFunc{
name: name,
f: func(db *gorm.DB, cfg *config.Config) error {
if hasRun(name, db) {
2021-02-21 14:02:19 +03:00
return nil
}
if err := db.Exec("UPDATE heartbeats SET created_at = time WHERE TRUE").Error; err != nil {
return err
}
setHasRun(name, db)
2021-02-21 14:02:19 +03:00
return nil
},
}
registerPostMigration(f)
}