Skip to content

Commit 1928400

Browse files
author
Lasim
committed
feat: Implement satellite registration token management system
1 parent 4e7c699 commit 1928400

File tree

11 files changed

+4627
-0
lines changed

11 files changed

+4627
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
CREATE TABLE `satelliteRegistrationTokens` (
2+
`id` text PRIMARY KEY NOT NULL,
3+
`token_type` text NOT NULL,
4+
`team_id` text,
5+
`token_hash` text NOT NULL,
6+
`token_prefix` text NOT NULL,
7+
`created_by` text NOT NULL,
8+
`permissions` text NOT NULL,
9+
`used` integer DEFAULT false NOT NULL,
10+
`used_at` text,
11+
`used_by_satellite_id` text,
12+
`expires_at` text NOT NULL,
13+
`created_at` text NOT NULL,
14+
FOREIGN KEY (`team_id`) REFERENCES `teams`(`id`) ON UPDATE no action ON DELETE cascade,
15+
FOREIGN KEY (`created_by`) REFERENCES `authUser`(`id`) ON UPDATE no action ON DELETE no action,
16+
FOREIGN KEY (`used_by_satellite_id`) REFERENCES `satellites`(`id`) ON UPDATE no action ON DELETE no action
17+
);
18+
--> statement-breakpoint
19+
CREATE UNIQUE INDEX `satelliteRegistrationTokens_token_hash_unique` ON `satelliteRegistrationTokens` (`token_hash`);--> statement-breakpoint
20+
CREATE INDEX `satelliteRegistrationTokens_token_hash_idx` ON `satelliteRegistrationTokens` (`token_hash`);--> statement-breakpoint
21+
CREATE INDEX `satelliteRegistrationTokens_team_scope_idx` ON `satelliteRegistrationTokens` (`team_id`,`token_type`);--> statement-breakpoint
22+
CREATE INDEX `satelliteRegistrationTokens_expiration_idx` ON `satelliteRegistrationTokens` (`expires_at`);--> statement-breakpoint
23+
CREATE INDEX `satelliteRegistrationTokens_creator_idx` ON `satelliteRegistrationTokens` (`created_by`);--> statement-breakpoint
24+
CREATE INDEX `satelliteRegistrationTokens_usage_idx` ON `satelliteRegistrationTokens` (`used`,`used_at`);--> statement-breakpoint
25+
PRAGMA foreign_keys=OFF;--> statement-breakpoint
26+
CREATE TABLE `__new_mcpServerInstallations` (
27+
`id` text PRIMARY KEY NOT NULL,
28+
`team_id` text NOT NULL,
29+
`server_id` text NOT NULL,
30+
`created_by` text NOT NULL,
31+
`installation_name` text NOT NULL,
32+
`installation_type` text DEFAULT 'global' NOT NULL,
33+
`team_args` text,
34+
`team_env` text,
35+
`team_headers` text,
36+
`created_at` integer NOT NULL,
37+
`updated_at` integer NOT NULL,
38+
`last_used_at` integer,
39+
FOREIGN KEY (`team_id`) REFERENCES `teams`(`id`) ON UPDATE no action ON DELETE cascade,
40+
FOREIGN KEY (`server_id`) REFERENCES `mcpServers`(`id`) ON UPDATE no action ON DELETE cascade,
41+
FOREIGN KEY (`created_by`) REFERENCES `authUser`(`id`) ON UPDATE no action ON DELETE no action
42+
);
43+
--> statement-breakpoint
44+
INSERT INTO `__new_mcpServerInstallations`("id", "team_id", "server_id", "created_by", "installation_name", "installation_type", "team_args", "team_env", "team_headers", "created_at", "updated_at", "last_used_at") SELECT "id", "team_id", "server_id", "created_by", "installation_name", "installation_type", "team_args", "team_env", "team_headers", "created_at", "updated_at", "last_used_at" FROM `mcpServerInstallations`;--> statement-breakpoint
45+
DROP TABLE `mcpServerInstallations`;--> statement-breakpoint
46+
ALTER TABLE `__new_mcpServerInstallations` RENAME TO `mcpServerInstallations`;--> statement-breakpoint
47+
PRAGMA foreign_keys=ON;--> statement-breakpoint
48+
CREATE INDEX `mcp_installations_team_name_idx` ON `mcpServerInstallations` (`team_id`,`installation_name`);--> statement-breakpoint
49+
CREATE INDEX `mcp_installations_team_server_idx` ON `mcpServerInstallations` (`team_id`,`server_id`);--> statement-breakpoint
50+
CREATE INDEX `mcp_installations_created_by_idx` ON `mcpServerInstallations` (`created_by`);

0 commit comments

Comments
 (0)