Skip to content

Commit

Permalink
Add migration to remove obsolete subscribers.campaigns field
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Aug 14, 2021
1 parent 1be8c7d commit 923b882
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 4 additions & 0 deletions internal/migrations/v2.0.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
13 changes: 6 additions & 7 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 923b882

Please sign in to comment.