Brings the working codebase (Next.js app, auth system, Stripe billing, Docker/deploy config, tests, docs) into version control on top of the placeholder initial commit, and adds account self-deletion (Danger Zone in Settings, password + typed-email confirmation, cascading DB cleanup, Stripe cancellation) per GDPR right-to-erasure. Excludes local build caches, node_modules, and internal agent scratch files; .gitignore hardened to keep those out going forward. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
40 lines
2.5 KiB
SQL
40 lines
2.5 KiB
SQL
CREATE TABLE "email_verification_tokens" (
|
|
"id" varchar(64) PRIMARY KEY NOT NULL,
|
|
"user_id" varchar(64) NOT NULL,
|
|
"email" varchar(255) NOT NULL,
|
|
"expires_at" timestamp NOT NULL,
|
|
"consumed_at" timestamp,
|
|
"created_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "oauth_accounts" (
|
|
"id" varchar(64) PRIMARY KEY NOT NULL,
|
|
"user_id" varchar(64) NOT NULL,
|
|
"provider" varchar(32) NOT NULL,
|
|
"provider_account_id" varchar(255) NOT NULL,
|
|
"created_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "sessions" (
|
|
"id" varchar(64) PRIMARY KEY NOT NULL,
|
|
"user_id" varchar(64) NOT NULL,
|
|
"expires_at" timestamp NOT NULL,
|
|
"user_agent" varchar(255),
|
|
"ip_hash" varchar(64),
|
|
"created_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "users" ADD COLUMN "email_key" varchar(255);--> statement-breakpoint
|
|
ALTER TABLE "users" ADD COLUMN "name" varchar(160);--> statement-breakpoint
|
|
ALTER TABLE "users" ADD COLUMN "password_hash" varchar(255);--> statement-breakpoint
|
|
ALTER TABLE "users" ADD COLUMN "email_verified_at" timestamp;--> statement-breakpoint
|
|
ALTER TABLE "email_verification_tokens" ADD CONSTRAINT "email_verification_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "oauth_accounts" ADD CONSTRAINT "oauth_accounts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "idx_email_verification_user_id" ON "email_verification_tokens" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_email_verification_expires_at" ON "email_verification_tokens" USING btree ("expires_at");--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "uq_oauth_provider_account" ON "oauth_accounts" USING btree ("provider","provider_account_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_oauth_accounts_user_id" ON "oauth_accounts" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_sessions_user_id" ON "sessions" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_sessions_expires_at" ON "sessions" USING btree ("expires_at");--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "uq_users_email_key" ON "users" USING btree ("email_key"); |