mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-09-27 13:50:03 +00:00
11 lines
390 B
PL/PgSQL
11 lines
390 B
PL/PgSQL
-- 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;
|