39 lines
1.8 KiB
SQL
39 lines
1.8 KiB
SQL
CREATE TABLE `connection_approvals` (
|
|
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
`owner_id` integer NOT NULL,
|
|
`connection_id` integer NOT NULL,
|
|
`project_id` integer NOT NULL,
|
|
`session_id` integer,
|
|
`task_id` integer,
|
|
`agent_id` integer,
|
|
`agent_name` text,
|
|
`kind` text NOT NULL,
|
|
`method` text NOT NULL,
|
|
`log_path` text NOT NULL,
|
|
`summary` text NOT NULL,
|
|
`fingerprint` text NOT NULL,
|
|
`request_enc` text NOT NULL,
|
|
`idem_key` text NOT NULL,
|
|
`status` text DEFAULT 'pending' NOT NULL,
|
|
`decided_by` integer,
|
|
`decided_at` integer,
|
|
`expires_at` integer NOT NULL,
|
|
`waiting_until` integer,
|
|
`result_enc` text,
|
|
`result_reason` text,
|
|
`started_at` integer,
|
|
`finished_at` integer,
|
|
`delivered_at` 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 cascade,
|
|
FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
FOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE set null,
|
|
FOREIGN KEY (`task_id`) REFERENCES `tasks`(`id`) ON UPDATE no action ON DELETE set null,
|
|
FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE set null,
|
|
FOREIGN KEY (`decided_by`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `connection_approvals_owner` ON `connection_approvals` (`owner_id`,`status`);--> statement-breakpoint
|
|
CREATE INDEX `connection_approvals_fp` ON `connection_approvals` (`project_id`,`fingerprint`);--> statement-breakpoint
|
|
CREATE INDEX `connection_approvals_status` ON `connection_approvals` (`status`); |