CREATE TABLE "plex_accounts" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"user_id" uuid NOT NULL,
	"plex_user_id" text NOT NULL,
	"plex_uuid" text,
	"plex_username" text NOT NULL,
	"plex_email" text,
	"libraries_shared_at" timestamp,
	"shared_section_ids" text[],
	"linked_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL,
	CONSTRAINT "plex_accounts_user_id_unique" UNIQUE("user_id"),
	CONSTRAINT "plex_accounts_plex_user_id_unique" UNIQUE("plex_user_id")
);
--> statement-breakpoint
ALTER TABLE "plex_accounts" ADD CONSTRAINT "plex_accounts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;