Skip to content

Commit

Permalink
Add missing bounce_type to v2 migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Sep 17, 2021
1 parent 9302dfb commit fd8f5a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions internal/migrations/v2.0.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import (

// V2_0_0 performs the DB migrations for v.1.0.0.
func V2_0_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {
if _, err := db.Exec(`
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'bounce_type') THEN
CREATE TYPE bounce_type AS ENUM ('soft', 'hard', 'complaint');
END IF;
END$$;
`); err != nil {
return err
}

if _, err := db.Exec(`
CREATE TABLE IF NOT EXISTS bounces (
id SERIAL PRIMARY KEY,
Expand Down
2 changes: 1 addition & 1 deletion schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ CREATE TABLE campaigns (

DROP TABLE IF EXISTS campaign_lists CASCADE;
CREATE TABLE campaign_lists (
id BIGSERIAL PRIMARY KEY,
id BIGSERIAL PRIMARY KEY,
campaign_id INTEGER NOT NULL REFERENCES campaigns(id) ON DELETE CASCADE ON UPDATE CASCADE,

-- Lists may be deleted, so list_id is nullable
Expand Down

0 comments on commit fd8f5a9

Please sign in to comment.