db: schema upgrade 1: add titles.is_deleted column

This commit is contained in:
mappu 2018-04-02 16:53:55 +12:00
parent 9aa80bf772
commit 96b5318eca

20
DB.go
View File

@ -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
}