High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
JavaScript campaigncampaign-managementemail-marketingemail-subscriptionlistmonkmailing-listnewsletternewsletter-managementnewsletter-softwareself-hostedsms-gatewaysmtptransactional-emails
Fix (accidentally) broken migration scripts.
Kailash Nadh3335171960a5
diff --git a/internal/migrations/v2.3.0.go b/internal/migrations/v2.3.0.gonew file mode 100644index 00000000..55efe7ca--- /dev/null+++ b/internal/migrations/v2.3.0.go@@ -0,0 +1,41 @@+package migrations++import (+ "github.com/jmoiron/sqlx"+ "github.com/knadh/koanf/v2"+ "github.com/knadh/stuffbin"+)++// V2_2_0 performs the DB migrations for v.2.3.0.+func V2_3_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {+ if _, err := db.Exec(`ALTER TABLE media ADD COLUMN IF NOT EXISTS "meta" JSONB NOT NULL DEFAULT '{}'`); err != nil {+ return err+ }++ // Add `description` field to lists.+ if _, err := db.Exec(`ALTER TABLE lists ADD COLUMN IF NOT EXISTS "description" TEXT NOT NULL DEFAULT ''`); err != nil {+ return err+ }++ // Add archive publishing field to campaigns.+ if _, err := db.Exec(`ALTER TABLE campaigns+ ADD COLUMN IF NOT EXISTS archive BOOLEAN NOT NULL DEFAULT false,+ ADD COLUMN IF NOT EXISTS archive_meta JSONB NOT NULL DEFAULT '{}',+ ADD COLUMN IF NOT EXISTS archive_template_id INTEGER REFERENCES templates(id) ON DELETE SET DEFAULT DEFAULT 1+ `); err != nil {+ return err+ }++ // Insert new preference settings.+ if _, err := db.Exec(`+ INSERT INTO settings (key, value) VALUES+ ('app.site_name', '"Mailing list"'),+ ('app.enable_public_archive', 'true'),+ ('privacy.allow_preferences', 'false')+ ON CONFLICT DO NOTHING;+ `); err != nil {+ return err+ }++ return nil+}diff --git a/internal/migrations/v2.6.0.go b/internal/migrations/v2.6.0.godeleted file mode 100644index 0f209224..00000000--- a/internal/migrations/v2.6.0.go+++ /dev/null@@ -1,22 +0,0 @@-package migrations--import (- "github.com/jmoiron/sqlx"- "github.com/knadh/koanf/v2"- "github.com/knadh/stuffbin"-)--// V3_0_0 performs the DB migrations.-func V3_0_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {- // Insert new preference settings.- if _, err := db.Exec(`INSERT INTO settings (key, value) VALUES ('bounce.postmark', '{"enabled": false, "username": "", "password": ""}') ON CONFLICT DO NOTHING;`); err != nil {- return err- }-- // Fix incorrect "d" (day) time prefix in S3 expiry settings.- if _, err := db.Exec(`UPDATE settings SET value = '"167h"' WHERE key = 'upload.s3.expiry' AND value = '"14d"'`); err != nil {- return err- }-- return nil-}diff --git a/internal/migrations/v3.0.0.go b/internal/migrations/v3.0.0.goindex 62d7d16c..0f209224 100644--- a/internal/migrations/v3.0.0.go+++ b/internal/migrations/v3.0.0.go@@ -6,34 +6,15 @@ import ("github.com/knadh/stuffbin")-// V2_2_0 performs the DB migrations for v.2.2.0.-func V2_3_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {- if _, err := db.Exec(`ALTER TABLE media ADD COLUMN IF NOT EXISTS "meta" JSONB NOT NULL DEFAULT '{}'`); err != nil {- return err- }-- // Add `description` field to lists.- if _, err := db.Exec(`ALTER TABLE lists ADD COLUMN IF NOT EXISTS "description" TEXT NOT NULL DEFAULT ''`); err != nil {- return err- }-- // Add archive publishing field to campaigns.- if _, err := db.Exec(`ALTER TABLE campaigns- ADD COLUMN IF NOT EXISTS archive BOOLEAN NOT NULL DEFAULT false,- ADD COLUMN IF NOT EXISTS archive_meta JSONB NOT NULL DEFAULT '{}',- ADD COLUMN IF NOT EXISTS archive_template_id INTEGER REFERENCES templates(id) ON DELETE SET DEFAULT DEFAULT 1- `); err != nil {+// V3_0_0 performs the DB migrations.+func V3_0_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {+ // Insert new preference settings.+ if _, err := db.Exec(`INSERT INTO settings (key, value) VALUES ('bounce.postmark', '{"enabled": false, "username": "", "password": ""}') ON CONFLICT DO NOTHING;`); err != nil {return err}- // Insert new preference settings.- if _, err := db.Exec(`- INSERT INTO settings (key, value) VALUES- ('app.site_name', '"Mailing list"'),- ('app.enable_public_archive', 'true'),- ('privacy.allow_preferences', 'false')- ON CONFLICT DO NOTHING;- `); err != nil {+ // Fix incorrect "d" (day) time prefix in S3 expiry settings.+ if _, err := db.Exec(`UPDATE settings SET value = '"167h"' WHERE key = 'upload.s3.expiry' AND value = '"14d"'`); err != nil {return err}