From 96b5318eca5f37b4e2564526bf272bb85a200cb5 Mon Sep 17 00:00:00 2001 From: mappu Date: Mon, 2 Apr 2018 16:53:55 +1200 Subject: [PATCH] db: schema upgrade 1: add titles.is_deleted column --- DB.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/DB.go b/DB.go index 3f91ce9..1c80dc1 100644 --- a/DB.go +++ b/DB.go @@ -69,9 +69,10 @@ func (this *WikiDB) assertSchema() error { log.Printf("Found DB version %d\n", currentSchema) - // Schema 0 ==> Schema 1 + // if currentSchema == 0 { + // Schema 0 ==> Schema 1 log.Println("Upgrading to DB version 1") err := this.multiTx( @@ -96,6 +97,23 @@ func (this *WikiDB) assertSchema() error { currentSchema = 1 } + // + + if currentSchema == 1 { + log.Println("Upgrading to DB version 2") + + err := this.multiTx( + `ALTER TABLE titles ADD COLUMN is_deleted INTEGER DEFAULT 0;`, + `INSERT INTO schema (id) VALUES (2);`, + ) + if err != nil { + return err + } + currentSchema = 1 + } + + // + return nil }