From fd8f5a96c967b8782ed3f9f2885a6928a0792719 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Fri, 17 Sep 2021 20:18:53 +0530 Subject: [PATCH] Add missing `bounce_type` to v2 migration. --- internal/migrations/v2.0.0.go | 11 +++++++++++ schema.sql | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/migrations/v2.0.0.go b/internal/migrations/v2.0.0.go index 4e6b9a9..92f8dba 100644 --- a/internal/migrations/v2.0.0.go +++ b/internal/migrations/v2.0.0.go @@ -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, diff --git a/schema.sql b/schema.sql index 848f786..8a4f41b 100644 --- a/schema.sql +++ b/schema.sql @@ -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