ALTER TABLE "media" RENAME COLUMN "filename" TO "path";--> statement-breakpoint
ALTER TABLE "post_media" RENAME COLUMN "project_id" TO "post_id";--> statement-breakpoint
ALTER TABLE "post_media" DROP CONSTRAINT "post_media_project_id_posts_id_fk";
--> statement-breakpoint
DROP INDEX "media_filename_index";--> statement-breakpoint
DROP INDEX "post_media_post_id_index";--> statement-breakpoint
ALTER TABLE "post_media" DROP CONSTRAINT "post_media_project_id_media_id_pk";--> statement-breakpoint
ALTER TABLE "post_media" ADD CONSTRAINT "post_media_post_id_media_id_pk" PRIMARY KEY("post_id","media_id");--> statement-breakpoint
ALTER TABLE "media" ADD COLUMN "author" varchar(255);--> statement-breakpoint
ALTER TABLE "media" ADD COLUMN "caption" varchar(255);--> statement-breakpoint
ALTER TABLE "post_media" ADD CONSTRAINT "post_media_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_path_index" ON "media" USING btree ("path");--> statement-breakpoint
CREATE INDEX "post_media_post_id_index" ON "post_media" USING btree ("post_id");