zero2prod_axum/migrations/20240304195803_make_status_not_null_in_subscriptions.sql
2024-03-04 21:20:35 +01:00

11 lines
352 B
PL/PgSQL

-- Make Status Not Null In Subscriptions
-- We wrap the whole migration in a transaction to make sure
-- it succeeds or fails atomically.
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;