Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

0005_totp_2fa.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.

0005_totp_2fa.sqlBlame30 lines · 1 contributor
7298a17Claude1-- Gluecron migration 0005: Block B4 — TOTP 2FA + recovery codes.
2
3--> statement-breakpoint
4ALTER TABLE "sessions" ADD COLUMN IF NOT EXISTS "requires_2fa" boolean DEFAULT false NOT NULL;
5
6--> statement-breakpoint
7CREATE TABLE IF NOT EXISTS "user_totp" (
8 "user_id" uuid PRIMARY KEY NOT NULL,
9 "secret" text NOT NULL,
10 "enabled_at" timestamp,
11 "last_used_at" timestamp,
12 "created_at" timestamp DEFAULT now() NOT NULL,
13 CONSTRAINT "user_totp_user_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade
14);
15
16--> statement-breakpoint
17CREATE TABLE IF NOT EXISTS "user_recovery_codes" (
18 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
19 "user_id" uuid NOT NULL,
20 "code_hash" text NOT NULL,
21 "used_at" timestamp,
22 "created_at" timestamp DEFAULT now() NOT NULL,
23 CONSTRAINT "user_recovery_codes_user_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade
24);
25
26--> statement-breakpoint
27CREATE INDEX IF NOT EXISTS "recovery_codes_user" ON "user_recovery_codes" ("user_id");
28
29--> statement-breakpoint
30CREATE UNIQUE INDEX IF NOT EXISTS "recovery_codes_user_hash" ON "user_recovery_codes" ("user_id", "code_hash");