CREATE TABLE "edition" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"issue_number" integer NOT NULL,
	"feature" text NOT NULL,
	"updates" text NOT NULL,
	"top_flop" text NOT NULL,
	"og" text NOT NULL,
	"preview_id" uuid,
	"media_id" uuid,
	"published_at" timestamp NOT NULL,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "media" DROP CONSTRAINT "media_user_id_users_id_fk";
--> statement-breakpoint
DROP INDEX "media_type_index";--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "avatarId" uuid;--> statement-breakpoint
ALTER TABLE "edition" ADD CONSTRAINT "edition_preview_id_media_id_fk" FOREIGN KEY ("preview_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "edition" ADD CONSTRAINT "edition_media_id_media_id_fk" FOREIGN KEY ("media_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "users" ADD CONSTRAINT "users_avatarId_media_id_fk" FOREIGN KEY ("avatarId") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "media_mime_type_index" ON "media" USING btree ("mime_type");