CREATE TABLE "account" ( "id" uuid PRIMARY KEY, "account_id" text NOT NULL, "provider_id" text DEFAULT 'credential' NOT NULL, "user_id" uuid NOT NULL, "scope" text, "id_token" text, "password" text, "access_token" text, "refresh_token" text, "access_token_expires_at" timestamp, "refresh_token_expires_at" timestamp, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "apikey" ( "id" uuid PRIMARY KEY, "name" text, "start" text, "prefix" text, "key" text NOT NULL, "user_id" uuid NOT NULL, "refill_interval" integer, "refill_amount" integer, "last_refill_at" timestamp, "enabled" boolean DEFAULT true NOT NULL, "rate_limit_enabled" boolean DEFAULT false NOT NULL, "rate_limit_time_window" integer, "rate_limit_max" integer, "request_count" integer DEFAULT 0 NOT NULL, "remaining" integer, "last_request" timestamp, "expires_at" timestamp, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, "permissions" text, "metadata" jsonb ); --> statement-breakpoint CREATE TABLE "passkey" ( "id" uuid PRIMARY KEY, "name" text, "aaguid" text, "public_key" text NOT NULL, "credential_id" text NOT NULL, "counter" integer NOT NULL, "device_type" text NOT NULL, "backed_up" boolean DEFAULT false NOT NULL, "transports" text NOT NULL, "user_id" uuid NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "resume" ( "id" uuid PRIMARY KEY, "name" text NOT NULL, "slug" text NOT NULL, "tags" text[] DEFAULT '{}'::text[] NOT NULL, "is_public" boolean DEFAULT false NOT NULL, "is_locked" boolean DEFAULT false NOT NULL, "password" text, "data" jsonb NOT NULL, "user_id" uuid NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "resume_slug_user_id_unique" UNIQUE("slug","user_id") ); --> statement-breakpoint CREATE TABLE "resume_statistics" ( "id" uuid PRIMARY KEY, "views" integer DEFAULT 0 NOT NULL, "downloads" integer DEFAULT 0 NOT NULL, "last_viewed_at" timestamp, "last_downloaded_at" timestamp, "resume_id" uuid NOT NULL UNIQUE, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "session" ( "id" uuid PRIMARY KEY, "token" text NOT NULL UNIQUE, "ip_address" text, "user_agent" text, "user_id" uuid NOT NULL, "expires_at" timestamp NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "two_factor" ( "id" uuid PRIMARY KEY, "user_id" uuid NOT NULL, "secret" text, "backup_codes" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "user" ( "id" uuid PRIMARY KEY, "image" text, "name" text NOT NULL, "email" text NOT NULL UNIQUE, "email_verified" boolean DEFAULT false NOT NULL, "username" text NOT NULL UNIQUE, "display_username" text NOT NULL UNIQUE, "two_factor_enabled" boolean DEFAULT false NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "verification" ( "id" uuid PRIMARY KEY, "identifier" text NOT NULL UNIQUE, "value" text NOT NULL, "expires_at" timestamp NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE INDEX "account_user_id_index" ON "account" ("user_id");--> statement-breakpoint CREATE INDEX "passkey_user_id_index" ON "passkey" ("user_id");--> statement-breakpoint CREATE INDEX "resume_is_public_slug_user_id_index" ON "resume" ("is_public","slug","user_id");--> statement-breakpoint CREATE INDEX "session_token_user_id_index" ON "session" ("token","user_id");--> statement-breakpoint CREATE INDEX "two_factor_user_id_index" ON "two_factor" ("user_id");--> statement-breakpoint ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE;--> statement-breakpoint ALTER TABLE "apikey" ADD CONSTRAINT "apikey_user_id_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE;--> statement-breakpoint ALTER TABLE "passkey" ADD CONSTRAINT "passkey_user_id_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE;--> statement-breakpoint ALTER TABLE "resume" ADD CONSTRAINT "resume_user_id_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE;--> statement-breakpoint ALTER TABLE "resume_statistics" ADD CONSTRAINT "resume_statistics_resume_id_resume_id_fkey" FOREIGN KEY ("resume_id") REFERENCES "resume"("id") ON DELETE CASCADE;--> statement-breakpoint ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE;--> statement-breakpoint ALTER TABLE "two_factor" ADD CONSTRAINT "two_factor_user_id_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE;