feat: add status to subscriptions
This commit is contained in:
parent
fe5a596265
commit
5082db095a
3 changed files with 15 additions and 2 deletions
|
|
@ -0,0 +1,2 @@
|
|||
-- Add Status Column To Subscriptions Table
|
||||
ALTER TABLE subscriptions ADD COLUMN status TEXT NULL;
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
-- 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;
|
||||
|
|
@ -72,8 +72,8 @@ pub async fn insert_subscriber(
|
|||
) -> Result<(), sqlx::Error> {
|
||||
let _ = sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO subscriptions (id, email, name, subscribed_at)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
INSERT INTO subscriptions (id, email, name, subscribed_at, status)
|
||||
VALUES ($1, $2, $3, $4, 'confirmed')
|
||||
"#,
|
||||
Uuid::new_v4(),
|
||||
new_subscriber.email.as_ref(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue