Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Add migration to remove obsolete subscribers.campaigns field

Kailash Nadh923b882f05b5
diff --git a/internal/migrations/v2.0.0.go b/internal/migrations/v2.0.0.go
index ed601906..8123f14c 100644
--- a/internal/migrations/v2.0.0.go
+++ b/internal/migrations/v2.0.0.go
@@ -39,5 +39,9 @@ func V2_0_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {
return err
}
+ if _, err := db.Exec(`ALTER TABLE subscribers DROP COLUMN IF EXISTS campaigns; `); err != nil {
+ return err
+ }
+
return nil
}
diff --git a/models/models.go b/models/models.go
index dcf9c89f..f8c4f970 100644
--- a/models/models.go
+++ b/models/models.go
@@ -120,13 +120,12 @@ type User struct {
type Subscriber struct {
Base
- UUID string `db:"uuid" json:"uuid"`
- Email string `db:"email" json:"email"`
- Name string `db:"name" json:"name"`
- Attribs SubscriberAttribs `db:"attribs" json:"attribs"`
- Status string `db:"status" json:"status"`
- CampaignIDs pq.Int64Array `db:"campaigns" json:"-"`
- Lists types.JSONText `db:"lists" json:"lists"`
+ UUID string `db:"uuid" json:"uuid"`
+ Email string `db:"email" json:"email"`
+ Name string `db:"name" json:"name"`
+ Attribs SubscriberAttribs `db:"attribs" json:"attribs"`
+ Status string `db:"status" json:"status"`
+ Lists types.JSONText `db:"lists" json:"lists"`
// Pseudofield for getting the total number of subscribers
// in searches and queries.
diff --git a/schema.sql b/schema.sql
index 1b239379..e7ff006f 100644
--- a/schema.sql
+++ b/schema.sql
@@ -16,7 +16,6 @@ CREATE TABLE subscribers (
name TEXT NOT NULL,
attribs JSONB NOT NULL DEFAULT '{}',
status subscriber_status NOT NULL DEFAULT 'enabled',
- campaigns INTEGER[],
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()