fabrica

hanna/fabrica

562 bytes
Raw
1-- Email-address verification: a nullable verified timestamp plus single-use,
2-- expiring verification tokens. Addresses that predate this migration are
3-- trusted (back-filled as verified).
4ALTER TABLE user_emails ADD COLUMN verified_at BIGINT;
5UPDATE user_emails SET verified_at = created_at;
6
7CREATE TABLE email_tokens (
8 token TEXT PRIMARY KEY,
9 email_id TEXT NOT NULL REFERENCES user_emails(id) ON DELETE CASCADE,
10 expires_at BIGINT NOT NULL,
11 created_at BIGINT NOT NULL
12);
13CREATE INDEX idx_email_tokens_email ON email_tokens (email_id);