2021-02-13 15:04:47 +03:00
|
|
|
package migrations
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/muety/wakapi/config"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-02-14 18:01:31 +03:00
|
|
|
const name = "20210213-add_has_data_field"
|
2021-02-13 15:04:47 +03:00
|
|
|
f := migrationFunc{
|
2021-02-14 18:01:31 +03:00
|
|
|
name: name,
|
2021-02-13 15:04:47 +03:00
|
|
|
f: func(db *gorm.DB, cfg *config.Config) error {
|
2021-12-15 12:50:16 +03:00
|
|
|
if hasRun(name, db) {
|
2021-02-14 18:01:31 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := db.Exec("UPDATE users SET has_data = TRUE WHERE TRUE").Error; err != nil {
|
2021-02-13 15:04:47 +03:00
|
|
|
return err
|
|
|
|
}
|
2021-02-14 18:01:31 +03:00
|
|
|
|
2021-12-15 12:50:16 +03:00
|
|
|
setHasRun(name, db)
|
2021-02-13 15:04:47 +03:00
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
registerPostMigration(f)
|
|
|
|
}
|