Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix column drop on sqlite3 db update #269

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix column drop on sqlite3 db update
  • Loading branch information
Yannik committed Jul 16, 2021
commit 0f19619d2651134d04ce2ffd0fc9fab287532768
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