Skip to content

Commit d09d9b5

Browse files
authored
Update engine.go
1 parent bea87be commit d09d9b5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

models/db/engine.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ func NewEngine(ctx context.Context, migrateFunc func(*xorm.Engine) error) (err e
192192
}
193193

194194
if err = migrateFunc(x); err != nil {
195+
// The only case to re-run the installation on an installed instance is: users may want to recover an old database.
196+
// In such case, we should run the migrations first,
197+
// otherwise the table schemas may conflict in the normal startup migrations, because `syncTables` below already changed the schemas to the latest.
198+
// However, we should think carefully about should we support re-install on an installed instance, it may bring other problems, eg: secrets will be lost.
195199
return fmt.Errorf("migrate: %v", err)
196200
}
197201

0 commit comments

Comments
 (0)