CREATE TABLE "post_has_tag" (
	"post_id" uuid NOT NULL,
	"tag_id" uuid NOT NULL,
	"created_at" timestamp DEFAULT now() NOT NULL,
	CONSTRAINT "post_tag_post__primary" PRIMARY KEY("post_id","tag_id")
);
--> statement-breakpoint
DROP TABLE "post_tags" CASCADE;--> statement-breakpoint
ALTER TABLE "post_has_tag" ADD CONSTRAINT "post_has_tag_post_id_posts_id_fk" FOREIGN KEY ("post_id") REFERENCES "public"."posts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "post_has_tag" ADD CONSTRAINT "post_has_tag_tag_id_tags_id_fk" FOREIGN KEY ("tag_id") REFERENCES "public"."tags"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "post_tags_post_tag_idx" ON "post_has_tag" USING btree ("post_id","tag_id");--> statement-breakpoint
CREATE INDEX "post_tags_postId_idx" ON "post_has_tag" USING btree ("post_id");--> statement-breakpoint
CREATE INDEX "post_tags_tagId_idx" ON "post_has_tag" USING btree ("tag_id");