mirror of
https://github.com/h44z/wg-portal
synced 2025-02-26 05:49:14 +00:00
skip migrations for fresh databases
This commit is contained in:
parent
3ecb0925d6
commit
1c4d47293c
@ -116,6 +116,10 @@ func MigrateDatabase(db *gorm.DB, version string) error {
|
||||
lastVersion := DatabaseMigrationInfo{}
|
||||
db.Order("applied desc, version desc").FirstOrInit(&lastVersion)
|
||||
|
||||
if lastVersion.Version == "" {
|
||||
return nil // no previous version exists, no migrations to apply
|
||||
}
|
||||
|
||||
sort.Slice(migrations, func(i, j int) bool {
|
||||
return migrations[i].version < migrations[j].version
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user