Browse Source

Add v0.8.0 DB migrations.

Kailash Nadh 4 years ago
parent
commit
2e361c7371
2 changed files with 20 additions and 1 deletions
  1. 2 1
      cmd/upgrade.go
  2. 18 0
      internal/migrations/v0.8.0.go

+ 2 - 1
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
 	}
 

+ 18 - 0
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
+}