diff --git a/targets/hasura/migrations/1595231600880_alerts_uniq/down.sql b/targets/hasura/migrations/1595231600880_alerts_uniq/down.sql index 906d71e50..acbded61f 100644 --- a/targets/hasura/migrations/1595231600880_alerts_uniq/down.sql +++ b/targets/hasura/migrations/1595231600880_alerts_uniq/down.sql @@ -1,2 +1,2 @@ ALTER TABLE "public"."alerts" - DROP CONSTRAINT "alerts_ref_info_key"; + DROP IF EXISTS CONSTRAINT "alerts_ref_info_key"; diff --git a/targets/hasura/migrations/1595231600880_alerts_uniq/up.sql b/targets/hasura/migrations/1595231600880_alerts_uniq/up.sql index fcbb5923a..0041da1be 100644 --- a/targets/hasura/migrations/1595231600880_alerts_uniq/up.sql +++ b/targets/hasura/migrations/1595231600880_alerts_uniq/up.sql @@ -1,4 +1,8 @@ +ALTER TABLE "public"."alerts" + DROP CONSTRAINT IF EXISTS "alerts_ref_info_key"; -alter table "public"."alerts" add constraint "alerts_ref_info_key" unique ("ref", "info"); +ALTER TABLE "public"."alerts" + ADD CONSTRAINT "alerts_ref_info_key" UNIQUE ("ref", "info"); -DELETE FROM alerts where (info -> 'type') is null; +DELETE FROM alerts +WHERE (info -> 'type') IS NULL;