internal/store/migrations/0077_account_delete.up.sql
12 lines · 645 bytes
1-- Self-service account deletion (#322). A request waits for its mailed
2-- link in account_deletions; a confirmed one sets users.delete_after and
3-- disables the account until the reaper purges it. users.ghost marks the
4-- one account that takes over what deleted accounts wrote.
5CREATE TABLE account_deletions (
6 user_id INTEGER PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
7 token_hash TEXT NOT NULL UNIQUE,
8 created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
9 expires_at TEXT NOT NULL
10);
11ALTER TABLE users ADD COLUMN delete_after TEXT;
12ALTER TABLE users ADD COLUMN ghost INTEGER NOT NULL DEFAULT 0;