Skip to content

Commit

Permalink
Fix column drop on sqlite3 db update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannik committed Jul 16, 2021
1 parent 68bb6ab commit 0f19619
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,25 @@ func (d *acmedb) handleDBUpgradeTo1() error {
if Config.Database.Engine != "sqlite3" {
_, _ = tx.Exec("ALTER TABLE records DROP COLUMN IF EXISTS Value")
_, _ = tx.Exec("ALTER TABLE records DROP COLUMN IF EXISTS LastActive")
} else {
_, err = tx.Exec("ALTER TABLE records RENAME TO records_old")
if err != nil {
return err
}
_, err = tx.Exec(userTable)
if err != nil {
return err
}
insertSQL := `INSERT INTO records (Username, Password, Subdomain, AllowFrom)
SELECT Username, Password, Subdomain, AllowFrom FROM records_old`
_, err = tx.Exec(insertSQL)
if err != nil {
return err
}
_, err = tx.Exec("DROP TABLE records_old")
if err != nil {
return err
}
}
_, err = tx.Exec("UPDATE acmedns SET Value='1' WHERE Name='db_version'")
return err
Expand Down

0 comments on commit 0f19619

Please sign in to comment.