CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
0047_password_reset_tokens.sql
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| c63b860 | 1 | -- Block P1 — Password reset flow. |
| 2 | -- | |
| 3 | -- A forgot-password user has a path back to their account. Without this, | |
| 4 | -- every locked-out user is a permanent loss. | |
| 5 | -- | |
| 6 | -- Strictly additive — drop this table to remove the feature. No changes | |
| 7 | -- to `users`; password rotation happens via `users.password_hash` update | |
| 8 | -- triggered by `src/lib/password-reset.ts::consumeResetToken`. | |
| 9 | ||
| 10 | CREATE TABLE IF NOT EXISTS "password_reset_tokens" ( | |
| 11 | "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), | |
| 12 | "user_id" uuid NOT NULL REFERENCES "users"("id") ON DELETE CASCADE, | |
| 13 | "token_hash" text NOT NULL UNIQUE, | |
| 14 | "expires_at" timestamptz NOT NULL, | |
| 15 | "used_at" timestamptz, | |
| 16 | "request_ip" text, | |
| 17 | "created_at" timestamptz NOT NULL DEFAULT now() | |
| 18 | ); | |
| 19 | ||
| 20 | --> statement-breakpoint | |
| 21 | ||
| 22 | CREATE INDEX IF NOT EXISTS "idx_password_reset_tokens_user" | |
| 23 | ON "password_reset_tokens" ("user_id"); | |
| 24 | ||
| 25 | --> statement-breakpoint | |
| 26 | ||
| 27 | CREATE INDEX IF NOT EXISTS "idx_password_reset_tokens_expires" | |
| 28 | ON "password_reset_tokens" ("expires_at"); |