CREATE TABLE `beta_access_requests` ( `id` text PRIMARY KEY NOT NULL, `account_id` text NOT NULL, `status` text DEFAULT 'requested' NOT NULL, `preferred_os` text NOT NULL, `requested_slots` integer DEFAULT 1 NOT NULL, `use_case` text NOT NULL, `admin_response` text, `resolved_by` text, `invitation_grant_id` text, `requested_at` text NOT NULL, `resolved_at` text, `cancelled_at` text, `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`invitation_grant_id`) REFERENCES `entitlement_grants`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE UNIQUE INDEX `idx_beta_access_requests_one_pending` ON `beta_access_requests` (`account_id`) WHERE "beta_access_requests"."status" = 'requested';--> statement-breakpoint CREATE INDEX `idx_beta_access_requests_status_time` ON `beta_access_requests` (`status`,`requested_at`);--> statement-breakpoint CREATE INDEX `idx_beta_access_requests_account_time` ON `beta_access_requests` (`account_id`,`requested_at`);