Files

28 lines
1.0 KiB
SQL
Raw Permalink Normal View History

CREATE TABLE "account_deletion_requests" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"user_id" text NOT NULL,
"email" text,
"status" text DEFAULT 'pending' NOT NULL,
"reason" text,
"scheduled_for" timestamp with time zone NOT NULL,
"cancelled_at" timestamp with time zone,
"completed_at" timestamp with time zone,
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "consent_log" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"user_id" text,
"email" text,
"kind" text NOT NULL,
"granted" boolean NOT NULL,
"policy_version" text,
"source" text,
"ip_address" text,
"user_agent" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX "account_deletion_requests_pending_user_idx" ON "account_deletion_requests" USING btree ("user_id") WHERE status = 'pending';