CREATE TABLE "media" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"filename" varchar(255) NOT NULL,
	"user_id" uuid NOT NULL,
	"original_name" varchar(255) NOT NULL,
	"mime_type" varchar(100) NOT NULL,
	"size" integer NOT NULL,
	"width" integer,
	"height" integer,
	"alt" varchar(255),
	"url" varchar(255) NOT NULL,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "project" (
	"post_id" uuid PRIMARY KEY NOT NULL,
	"status" varchar(45) NOT NULL,
	"type" integer NOT NULL,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "media" ADD CONSTRAINT "media_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "project" ADD CONSTRAINT "project_post_id_posts_id_fk" FOREIGN KEY ("post_id") REFERENCES "public"."posts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "media_user_id_index" ON "media" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX "media_filename_index" ON "media" USING btree ("filename");--> statement-breakpoint
CREATE INDEX "project_status_index" ON "project" USING btree ("status");--> statement-breakpoint
CREATE INDEX "project_type_index" ON "project" USING btree ("type");--> statement-breakpoint
CREATE INDEX "project_created_at_index" ON "project" USING btree ("created_at");--> statement-breakpoint
CREATE INDEX "project_updated_at_index" ON "project" USING btree ("updated_at");