mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-05 04:13:50 +00:00
Squash merge PR #115 after resolving changelog and SQLite migration-map conflicts with current dev. Renumbered channel-context PostgreSQL migration to 000075 and bumped PG required schema to 75 plus SQLite schema to 44 so it follows the run timeline migration. Local checks passed: go test ./..., go build ./..., go build -tags sqliteonly ./..., go vet ./..., and pnpm -C ui/web build. PR CI run 26705617311 passed release-versioning, go, and web.
81 lines
3.8 KiB
SQL
81 lines
3.8 KiB
SQL
CREATE TABLE mcp_context_grants (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
channel_instance_id UUID NOT NULL REFERENCES channel_instances(id) ON DELETE CASCADE,
|
|
scope_type VARCHAR(32) NOT NULL,
|
|
scope_key VARCHAR(255) NOT NULL DEFAULT '',
|
|
server_id UUID NOT NULL REFERENCES mcp_servers(id) ON DELETE CASCADE,
|
|
enabled BOOLEAN NOT NULL DEFAULT true,
|
|
tool_allow JSONB,
|
|
tool_deny JSONB,
|
|
config_overrides JSONB,
|
|
granted_by VARCHAR(255) NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE(tenant_id, channel_instance_id, scope_type, scope_key, server_id)
|
|
);
|
|
|
|
CREATE INDEX idx_mcp_context_grants_scope ON mcp_context_grants(tenant_id, channel_instance_id, scope_type, scope_key);
|
|
CREATE INDEX idx_mcp_context_grants_server ON mcp_context_grants(server_id);
|
|
|
|
CREATE TABLE mcp_context_credentials (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
channel_instance_id UUID NOT NULL REFERENCES channel_instances(id) ON DELETE CASCADE,
|
|
scope_type VARCHAR(32) NOT NULL,
|
|
scope_key VARCHAR(255) NOT NULL DEFAULT '',
|
|
server_id UUID NOT NULL REFERENCES mcp_servers(id) ON DELETE CASCADE,
|
|
api_key TEXT,
|
|
headers BYTEA,
|
|
env BYTEA,
|
|
created_by VARCHAR(255) NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE(tenant_id, channel_instance_id, scope_type, scope_key, server_id)
|
|
);
|
|
|
|
CREATE INDEX idx_mcp_context_credentials_scope ON mcp_context_credentials(tenant_id, channel_instance_id, scope_type, scope_key);
|
|
CREATE INDEX idx_mcp_context_credentials_server ON mcp_context_credentials(server_id);
|
|
|
|
CREATE TABLE secure_cli_context_grants (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
channel_instance_id UUID NOT NULL REFERENCES channel_instances(id) ON DELETE CASCADE,
|
|
scope_type VARCHAR(32) NOT NULL,
|
|
scope_key VARCHAR(255) NOT NULL DEFAULT '',
|
|
binary_id UUID NOT NULL REFERENCES secure_cli_binaries(id) ON DELETE CASCADE,
|
|
deny_args JSONB,
|
|
deny_verbose JSONB,
|
|
timeout_seconds INTEGER,
|
|
tips TEXT,
|
|
encrypted_env BYTEA,
|
|
enabled BOOLEAN NOT NULL DEFAULT true,
|
|
granted_by VARCHAR(255) NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE(tenant_id, channel_instance_id, scope_type, scope_key, binary_id)
|
|
);
|
|
|
|
CREATE INDEX idx_secure_cli_context_grants_scope ON secure_cli_context_grants(tenant_id, channel_instance_id, scope_type, scope_key);
|
|
CREATE INDEX idx_secure_cli_context_grants_binary ON secure_cli_context_grants(binary_id);
|
|
|
|
CREATE TABLE secure_cli_context_credentials (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
channel_instance_id UUID NOT NULL REFERENCES channel_instances(id) ON DELETE CASCADE,
|
|
scope_type VARCHAR(32) NOT NULL,
|
|
scope_key VARCHAR(255) NOT NULL DEFAULT '',
|
|
binary_id UUID NOT NULL REFERENCES secure_cli_binaries(id) ON DELETE CASCADE,
|
|
encrypted_env BYTEA NOT NULL,
|
|
metadata JSONB NOT NULL DEFAULT '{}'::jsonb,
|
|
credential_type TEXT,
|
|
host_scope TEXT,
|
|
created_by VARCHAR(255) NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE(tenant_id, channel_instance_id, scope_type, scope_key, binary_id)
|
|
);
|
|
|
|
CREATE INDEX idx_secure_cli_context_credentials_scope ON secure_cli_context_credentials(tenant_id, channel_instance_id, scope_type, scope_key);
|
|
CREATE INDEX idx_secure_cli_context_credentials_binary ON secure_cli_context_credentials(binary_id);
|