tests/sqilte: enable FOREIGN_KEYS inside OpenTestConnection (#6641)

This commit is contained in:
gleb 2023-10-26 06:54:15 +03:00 committed by GitHub
parent 6bef318891
commit 78e905919f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -43,9 +43,6 @@ func init() {
}
RunMigrations()
if DB.Dialector.Name() == "sqlite" {
DB.Exec("PRAGMA foreign_keys = ON")
}
}
}
@ -89,7 +86,10 @@ func OpenTestConnection(cfg *gorm.Config) (db *gorm.DB, err error) {
db, err = gorm.Open(mysql.Open(dbDSN), cfg)
default:
log.Println("testing sqlite3...")
db, err = gorm.Open(sqlite.Open(filepath.Join(os.TempDir(), "gorm.db?_foreign_keys=on")), cfg)
db, err = gorm.Open(sqlite.Open(filepath.Join(os.TempDir(), "gorm.db")), cfg)
if err == nil {
db.Exec("PRAGMA foreign_keys = ON")
}
}
if err != nil {