CREATE TYPE "public"."generation_status" AS ENUM('pending', 'processing', 'completed', 'failed');--> statement-breakpoint CREATE TABLE "account" ( "id" text PRIMARY KEY NOT NULL, "account_id" text NOT NULL, "provider_id" text NOT NULL, "user_id" text NOT NULL, "access_token" text, "refresh_token" text, "id_token" text, "access_token_expires_at" timestamp, "refresh_token_expires_at" timestamp, "scope" text, "password" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp NOT NULL ); --> statement-breakpoint CREATE TABLE "jwks" ( "id" text PRIMARY KEY NOT NULL, "public_key" text NOT NULL, "private_key" text NOT NULL, "created_at" timestamp NOT NULL ); --> statement-breakpoint CREATE TABLE "session" ( "id" text PRIMARY KEY NOT NULL, "expires_at" timestamp NOT NULL, "token" text NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp NOT NULL, "ip_address" text, "user_agent" text, "user_id" text NOT NULL, CONSTRAINT "session_token_unique" UNIQUE("token") ); --> statement-breakpoint CREATE TABLE "user" ( "id" text PRIMARY KEY NOT NULL, "name" text NOT NULL, "email" text NOT NULL, "email_verified" boolean DEFAULT false NOT NULL, "image" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, "username" text, "display_username" text, "phone_number" text, "phone_number_verified" boolean, "role" text DEFAULT 'user', "lang" text DEFAULT 'en', CONSTRAINT "user_email_unique" UNIQUE("email"), CONSTRAINT "user_username_unique" UNIQUE("username"), CONSTRAINT "user_phone_number_unique" UNIQUE("phone_number") ); --> statement-breakpoint CREATE TABLE "verification" ( "id" text PRIMARY KEY NOT NULL, "identifier" text NOT NULL, "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 TABLE "nvwa_attribute_file" ( "id" serial PRIMARY KEY NOT NULL, "name" varchar(255) NOT NULL, "type" varchar(255) NOT NULL, "description" text, "url" varchar(255), "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "nvwa_generation" ( "id" serial PRIMARY KEY NOT NULL, "wireframe_id" integer NOT NULL, "prompt" text NOT NULL, "status" "generation_status" DEFAULT 'pending' NOT NULL, "generated_image_url" varchar(500), "error_message" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "nvwa_project" ( "id" serial PRIMARY KEY NOT NULL, "name" varchar(255) NOT NULL, "description" text, "user_id" text NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "nvwa_wireframe" ( "id" serial PRIMARY KEY NOT NULL, "project_id" integer NOT NULL, "name" varchar(255) NOT NULL, "canvas_data" jsonb, "description" text, "uploaded_file_id" integer, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "nvwa_generation" ADD CONSTRAINT "nvwa_generation_wireframe_id_nvwa_wireframe_id_fk" FOREIGN KEY ("wireframe_id") REFERENCES "public"."nvwa_wireframe"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "nvwa_project" ADD CONSTRAINT "nvwa_project_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "nvwa_wireframe" ADD CONSTRAINT "nvwa_wireframe_project_id_nvwa_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."nvwa_project"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "nvwa_wireframe" ADD CONSTRAINT "nvwa_wireframe_uploaded_file_id_nvwa_attribute_file_id_fk" FOREIGN KEY ("uploaded_file_id") REFERENCES "public"."nvwa_attribute_file"("id") ON DELETE set null ON UPDATE no action;