sqlite: restore busy_timeout pragma (#30696)

This commit is contained in:
andig 2026-06-10 13:31:13 +02:00 • committed by GitHub
parent 23bab534e6
commit 6cf3ea92d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,18 +52,17 @@ func New(driver, dsn string) (*gorm.DB, error) {
filePath = file
// TODO WAL mode "journal_mode(WAL)", "synchronous(NORMAL)"
for _, pragma := range []string{"foreign_keys(1)", "auto_vacuum(INCREMENTAL)"} {
// Add busy_timeout pragma if not already present
for _, pragma := range []string{"busy_timeout(5000)", "foreign_keys(1)", "auto_vacuum(INCREMENTAL)"} {
// add pragma if not already present
if short, _, _ := strings.Cut(pragma, "("); strings.Contains(params, "_pragma="+short) {
continue
}
// Append '&' if there are existing connection parameters
// append '&' if there are existing connection parameters
if len(params) > 0 {
params += "&"
}
// Add busy_timeout pragma to connection parameters
params += "_pragma=" + pragma
}