Do not apply the FK migrations on startup

This commit is contained in:
Juan Font Alonso 2021-06-24 23:05:26 +02:00
parent d67be9ef58
commit d8e0b16512

8
db.go
View file

@ -50,9 +50,13 @@ func (h *Headscale) db() (*gorm.DB, error) {
var err error
switch h.dbType {
case "sqlite3":
db, err = gorm.Open(sqlite.Open(h.dbString), &gorm.Config{})
db, err = gorm.Open(sqlite.Open(h.dbString), &gorm.Config{
DisableForeignKeyConstraintWhenMigrating: true,
})
case "postgres":
db, err = gorm.Open(postgres.Open(h.dbString), &gorm.Config{})
db, err = gorm.Open(postgres.Open(h.dbString), &gorm.Config{
DisableForeignKeyConstraintWhenMigrating: true,
})
}
if err != nil {