CREATE TABLE `theme_policies` (
	`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
	`did` text NOT NULL,
	`rkey` text NOT NULL,
	`cid` text NOT NULL,
	`default_light_theme_uri` text NOT NULL,
	`default_dark_theme_uri` text NOT NULL,
	`allow_user_choice` integer NOT NULL,
	`indexed_at` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `theme_policies_did_rkey_idx` ON `theme_policies` (`did`,`rkey`);--> statement-breakpoint
CREATE TABLE `theme_policy_available_themes` (
	`policy_id` integer NOT NULL,
	`theme_uri` text NOT NULL,
	`theme_cid` text NOT NULL,
	PRIMARY KEY(`policy_id`, `theme_uri`),
	FOREIGN KEY (`policy_id`) REFERENCES `theme_policies`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `themes` (
	`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
	`did` text NOT NULL,
	`rkey` text NOT NULL,
	`cid` text NOT NULL,
	`name` text NOT NULL,
	`color_scheme` text NOT NULL,
	`tokens` text NOT NULL,
	`css_overrides` text,
	`font_urls` text,
	`created_at` integer NOT NULL,
	`indexed_at` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `themes_did_rkey_idx` ON `themes` (`did`,`rkey`);