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 {
|
2021-12-15 12:50:16 +03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-12-15 12:50:16 +03:00
|
|
|
setHasRun(name, db)
|
2021-02-21 14:02:19 +03:00
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
registerPostMigration(f)
|
|
|
|
}
|