From d8e0b165128eefd59821647b992d30f26b633620 Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Thu, 24 Jun 2021 23:05:26 +0200 Subject: [PATCH] Do not apply the FK migrations on startup --- db.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db.go b/db.go index f849d01..d7ce66e 100644 --- a/db.go +++ b/db.go @@ -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 {