CREATE TABLE IF NOT EXISTS recovery_codes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
account_id TEXT NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
code_hash BLOB NOT NULL,
created_at INTEGER NOT NULL,
used_at INTEGER,
UNIQUE(account_id, code_hash)
);
CREATE INDEX IF NOT EXISTS recovery_codes_account_idx
ON recovery_codes(account_id, used_at);
CREATE TABLE IF NOT EXISTS recovery_codes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
account_id TEXT NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
code_hash BLOB NOT NULL,
created_at INTEGER NOT NULL,
used_at INTEGER,
UNIQUE(account_id, code_hash)
);
CREATE INDEX IF NOT EXISTS recovery_codes_account_idx
ON recovery_codes(account_id, used_at);