1+ CREATE TABLE `devices ` (
2+ ` id` text PRIMARY KEY NOT NULL ,
3+ ` user_id` text NOT NULL ,
4+ ` device_name` text NOT NULL ,
5+ ` hostname` text ,
6+ ` hardware_id` text ,
7+ ` os_type` text ,
8+ ` os_version` text ,
9+ ` arch` text ,
10+ ` node_version` text ,
11+ ` last_ip` text ,
12+ ` user_agent` text ,
13+ ` is_active` integer DEFAULT true NOT NULL ,
14+ ` is_trusted` integer DEFAULT true NOT NULL ,
15+ ` last_login_at` integer ,
16+ ` last_activity_at` integer ,
17+ ` created_at` integer NOT NULL ,
18+ ` updated_at` integer NOT NULL ,
19+ FOREIGN KEY (` user_id` ) REFERENCES ` authUser` (` id` ) ON UPDATE no action ON DELETE cascade
20+ );
21+ -- > statement-breakpoint
22+ CREATE UNIQUE INDEX `devices_hardware_id_unique ` ON ` devices` (` hardware_id` );-- > statement-breakpoint
23+ CREATE INDEX `devices_user_idx ` ON ` devices` (` user_id` );-- > statement-breakpoint
24+ CREATE INDEX `devices_hardware_id_idx ` ON ` devices` (` hardware_id` );-- > statement-breakpoint
25+ CREATE INDEX `devices_active_idx ` ON ` devices` (` is_active` );-- > statement-breakpoint
26+ CREATE INDEX `devices_last_activity_idx ` ON ` devices` (` last_activity_at` );-- > statement-breakpoint
27+ PRAGMA foreign_keys= OFF;-- > statement-breakpoint
28+ CREATE TABLE `__new_mcpUserConfigurations ` (
29+ ` id` text PRIMARY KEY NOT NULL ,
30+ ` installation_id` text NOT NULL ,
31+ ` user_id` text NOT NULL ,
32+ ` device_id` text NOT NULL ,
33+ ` user_args` text ,
34+ ` user_env` text ,
35+ ` created_at` integer NOT NULL ,
36+ ` updated_at` integer NOT NULL ,
37+ ` last_used_at` integer ,
38+ FOREIGN KEY (` installation_id` ) REFERENCES ` mcpServerInstallations` (` id` ) ON UPDATE no action ON DELETE cascade ,
39+ FOREIGN KEY (` user_id` ) REFERENCES ` authUser` (` id` ) ON UPDATE no action ON DELETE cascade ,
40+ FOREIGN KEY (` device_id` ) REFERENCES ` devices` (` id` ) ON UPDATE no action ON DELETE cascade
41+ );
42+ -- > statement-breakpoint
43+ INSERT INTO ` __new_mcpUserConfigurations` (" id" , " installation_id" , " user_id" , " device_id" , " user_args" , " user_env" , " created_at" , " updated_at" , " last_used_at" ) SELECT " id" , " installation_id" , " user_id" , " device_id" , " user_args" , " user_env" , " created_at" , " updated_at" , " last_used_at" FROM ` mcpUserConfigurations` ;-- > statement-breakpoint
44+ DROP TABLE ` mcpUserConfigurations` ;-- > statement-breakpoint
45+ ALTER TABLE ` __new_mcpUserConfigurations` RENAME TO ` mcpUserConfigurations` ;-- > statement-breakpoint
46+ PRAGMA foreign_keys= ON ;-- > statement-breakpoint
47+ CREATE INDEX `mcp_user_configs_installation_user_device_idx ` ON ` mcpUserConfigurations` (` installation_id` ,` user_id` ,` device_id` );-- > statement-breakpoint
48+ CREATE INDEX `mcp_user_configs_device_idx ` ON ` mcpUserConfigurations` (` device_id` );-- > statement-breakpoint
49+ CREATE INDEX `mcp_user_configs_user_idx ` ON ` mcpUserConfigurations` (` user_id` );-- > statement-breakpoint
50+ CREATE INDEX `mcp_user_configs_installation_idx ` ON ` mcpUserConfigurations` (` installation_id` );-- > statement-breakpoint
51+ CREATE INDEX `mcp_user_configs_unique_user_installation_device ` ON ` mcpUserConfigurations` (` installation_id` ,` user_id` ,` device_id` );
0 commit comments