CREATE TABLE `factory_access_links` (
	`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
	`request_type` text NOT NULL,
	`request_id` integer NOT NULL,
	`token` text NOT NULL,
	`enabled` integer DEFAULT true NOT NULL,
	`created_at` integer NOT NULL,
	`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `factory_access_links_token_unique` ON `factory_access_links` (`token`);--> statement-breakpoint
CREATE UNIQUE INDEX `factory_access_request_unique` ON `factory_access_links` (`request_type`,`request_id`);--> statement-breakpoint
CREATE TABLE `project_files` (
	`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
	`request_type` text NOT NULL,
	`request_id` integer NOT NULL,
	`label` text NOT NULL,
	`category` text DEFAULT 'production' NOT NULL,
	`storage_key` text NOT NULL,
	`file_name` text NOT NULL,
	`content_type` text NOT NULL,
	`size_bytes` integer NOT NULL,
	`factory_visible` integer DEFAULT false NOT NULL,
	`share_token` text NOT NULL,
	`created_at` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `project_files_storage_key_unique` ON `project_files` (`storage_key`);--> statement-breakpoint
CREATE UNIQUE INDEX `project_files_share_token_unique` ON `project_files` (`share_token`);--> statement-breakpoint
CREATE INDEX `project_files_request_idx` ON `project_files` (`request_type`,`request_id`);