CREATE TABLE `connection_grants` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `connection_id` integer NOT NULL, `project_id` integer NOT NULL, `agent_id` integer, `operations` text NOT NULL, `created_by` integer, `created_at` integer DEFAULT (cast(unixepoch('subsec') * 1000 as integer)) NOT NULL, FOREIGN KEY (`connection_id`) REFERENCES `connections`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null ); --> statement-breakpoint CREATE INDEX `connection_grants_project` ON `connection_grants` (`project_id`);--> statement-breakpoint CREATE INDEX `connection_grants_connection` ON `connection_grants` (`connection_id`);--> statement-breakpoint CREATE TABLE `connection_log` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `owner_id` integer, `connection_id` integer, `connection_name` text, `project_id` integer, `session_id` integer, `agent_id` integer, `agent_name` text, `method` text NOT NULL, `path` text NOT NULL, `decision` text NOT NULL, `reason` text, `status_code` integer, `created_at` integer DEFAULT (cast(unixepoch('subsec') * 1000 as integer)) NOT NULL, FOREIGN KEY (`owner_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`connection_id`) REFERENCES `connections`(`id`) ON UPDATE no action ON DELETE set null, FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE set null, FOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE set null, FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE set null ); --> statement-breakpoint CREATE INDEX `connection_log_owner` ON `connection_log` (`owner_id`,`id`);--> statement-breakpoint CREATE INDEX `connection_log_session_created` ON `connection_log` (`session_id`,`created_at`);--> statement-breakpoint CREATE TABLE `connections` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `owner_id` integer NOT NULL, `name` text NOT NULL, `base_url` text NOT NULL, `auth_kind` text DEFAULT 'bearer' NOT NULL, `auth_header` text, `secret_enc` text, `status` text DEFAULT 'active' NOT NULL, `revoked_at` integer, `last_used_at` integer, `created_at` integer DEFAULT (cast(unixepoch('subsec') * 1000 as integer)) NOT NULL, `updated_at` integer DEFAULT (cast(unixepoch('subsec') * 1000 as integer)) NOT NULL, FOREIGN KEY (`owner_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE UNIQUE INDEX `connections_owner_name` ON `connections` (`owner_id`,`name`);