From 2e361c73711f056811521ba69243ab522ead6a8c Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 18 Oct 2020 20:25:33 +0530 Subject: [PATCH] Add v0.8.0 DB migrations. --- cmd/upgrade.go | 3 ++- internal/migrations/v0.8.0.go | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 internal/migrations/v0.8.0.go diff --git a/cmd/upgrade.go b/cmd/upgrade.go index 48f525f..44eb4be 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -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 } diff --git a/internal/migrations/v0.8.0.go b/internal/migrations/v0.8.0.go new file mode 100644 index 0000000..5e7537b --- /dev/null +++ b/internal/migrations/v0.8.0.go @@ -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 +}