peppa/packages/db/migrations/0032_access_requests.sql
peppa-bot 6b8a248d0c
All checks were successful
peppa/lint lint: success за 2с
peppa/typecheck typecheck: success за 46с
peppa/build build: success за 33с
peppa/test test: success за 1429с
peppa-ci / ci (pull_request) Successful in 25m58s
Merge branch 'main' into task/pep-250
Конфликты с PEP-251 (протоколы Access Hub): миграция запросов доступа — 0032,
список подключений, MCP агента и переводы — обе стороны; память в пределе.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 14:47:26 +00:00

32 lines
1.6 KiB
SQL

CREATE TABLE `access_requests` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`project_id` integer NOT NULL,
`owner_id` integer NOT NULL,
`task_id` integer,
`session_id` integer,
`agent_id` integer,
`agent_name` text,
`catalog_id` text,
`host` text,
`service_key` text NOT NULL,
`purpose` text NOT NULL,
`mode` text DEFAULT 'read' NOT NULL,
`status` text DEFAULT 'open' NOT NULL,
`reason` text,
`connection_id` integer,
`repeats` integer DEFAULT 0 NOT NULL,
`decided_by` integer,
`decided_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 (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`owner_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`task_id`) REFERENCES `tasks`(`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,
FOREIGN KEY (`connection_id`) REFERENCES `connections`(`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 `access_requests_project_service` ON `access_requests` (`project_id`,`service_key`,`status`);--> statement-breakpoint
CREATE INDEX `access_requests_owner` ON `access_requests` (`owner_id`,`status`);