upgrade all the db versions, not just one at a time

This commit is contained in:
Ted Unangst 2019-07-25 09:53:53 -04:00
parent f003de9cc9
commit 9a84d0dc7c
2 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,9 @@
changelog changelog
-- 0.7.6
+ Fix a bug where upgrades would not complete in one step.
-- 0.7.5 -- 0.7.5
+ Fix a bug (introdcued 0.7.4) preventing new user creation from working. + Fix a bug (introdcued 0.7.4) preventing new user creation from working.

View File

@ -88,26 +88,32 @@ func upgradedb() {
doordie(db, "update honks set honker = ?, whofore = 2 where userid = ? and honker = '' and what = 'bonk'", h, u.UserID) doordie(db, "update honks set honker = ?, whofore = 2 where userid = ? and honker = '' and what = 'bonk'", h, u.UserID)
} }
doordie(db, "update config set value = 8 where key = 'dbversion'") doordie(db, "update config set value = 8 where key = 'dbversion'")
fallthrough
case 8: case 8:
doordie(db, "alter table files add column local integer") doordie(db, "alter table files add column local integer")
doordie(db, "update files set local = 1") doordie(db, "update files set local = 1")
doordie(db, "update config set value = 9 where key = 'dbversion'") doordie(db, "update config set value = 9 where key = 'dbversion'")
fallthrough
case 9: case 9:
doordie(db, "drop table xonkers") doordie(db, "drop table xonkers")
doordie(db, "create table xonkers (xonkerid integer primary key, name text, info text, flavor text)") doordie(db, "create table xonkers (xonkerid integer primary key, name text, info text, flavor text)")
doordie(db, "create index idx_xonkername on xonkers(name)") doordie(db, "create index idx_xonkername on xonkers(name)")
doordie(db, "update config set value = 10 where key = 'dbversion'") doordie(db, "update config set value = 10 where key = 'dbversion'")
fallthrough
case 10: case 10:
doordie(db, "update zonkers set wherefore = 'zomain' where wherefore = 'zurl'") doordie(db, "update zonkers set wherefore = 'zomain' where wherefore = 'zurl'")
doordie(db, "update zonkers set wherefore = 'zord' where wherefore = 'zword'") doordie(db, "update zonkers set wherefore = 'zord' where wherefore = 'zword'")
doordie(db, "update config set value = 11 where key = 'dbversion'") doordie(db, "update config set value = 11 where key = 'dbversion'")
fallthrough
case 11: case 11:
doordie(db, "alter table users add column options text") doordie(db, "alter table users add column options text")
doordie(db, "update users set options = ''") doordie(db, "update users set options = ''")
doordie(db, "update config set value = 12 where key = 'dbversion'") doordie(db, "update config set value = 12 where key = 'dbversion'")
fallthrough
case 12: case 12:
doordie(db, "create index idx_honksoonker on honks(oonker)") doordie(db, "create index idx_honksoonker on honks(oonker)")
doordie(db, "update config set value = 13 where key = 'dbversion'") doordie(db, "update config set value = 13 where key = 'dbversion'")
fallthrough
case 13: case 13:
default: default:
log.Fatalf("can't upgrade unknown version %d", dbversion) log.Fatalf("can't upgrade unknown version %d", dbversion)