From 70334b9fc4c10644398e6e20cc27c7bd82b98e18 Mon Sep 17 00:00:00 2001 From: LukeMathWalker Date: Sun, 7 Mar 2021 18:53:52 +0000 Subject: [PATCH] Make status mandatory. --- ...07184428_make_status_not_null_in_subscriptions.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 migrations/20210307184428_make_status_not_null_in_subscriptions.sql diff --git a/migrations/20210307184428_make_status_not_null_in_subscriptions.sql b/migrations/20210307184428_make_status_not_null_in_subscriptions.sql new file mode 100644 index 0000000..3aec733 --- /dev/null +++ b/migrations/20210307184428_make_status_not_null_in_subscriptions.sql @@ -0,0 +1,11 @@ +-- We wrap the whole migration in a transaction to make sure +-- it succeeds or fails atomically. +-- `sqlx` does not do it automatically for us. +BEGIN; + -- Backfill `status` for historical entries + UPDATE subscriptions + SET status = 'confirmed' + WHERE status IS NULL; + -- Make `status` mandatory + ALTER TABLE subscriptions ALTER COLUMN status SET NOT NULL; +COMMIT;