Add v0.8.0 DB migrations.

This commit is contained in:
Kailash Nadh 2020-10-18 20:25:33 +05:30
parent f6511b68d8
commit 2e361c7371
2 changed files with 20 additions and 1 deletions

View File

@ -27,6 +27,7 @@ type migFunc struct {
var migList = []migFunc{
{"v0.4.0", migrations.V0_4_0},
{"v0.7.0", migrations.V0_7_0},
{"v0.8.0", migrations.V0_8_0},
}
// upgrade upgrades the database to the current version by running SQL migration files
@ -52,7 +53,7 @@ func upgrade(db *sqlx.DB, fs stuffbin.FileSystem, prompt bool) {
// No migrations to run.
if len(toRun) == 0 {
lo.Printf("no upgrades to run. Database is up-to-date.")
lo.Printf("no upgrades to run. Database is up to date.")
return
}

View File

@ -0,0 +1,18 @@
package migrations
import (
"github.com/jmoiron/sqlx"
"github.com/knadh/koanf"
"github.com/knadh/stuffbin"
)
// V0_8_0 performs the DB migrations for v.0.8.0.
func V0_8_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {
_, err := db.Exec(`
INSERT INTO settings (key, value) VALUES ('privacy.individual_tracking', 'false')
ON CONFLICT DO NOTHING;
INSERT INTO settings (key, value) VALUES ('messengers', '[]')
ON CONFLICT DO NOTHING;
`)
return err
}