Files
archie/internal/platform/pg/migrations/00002_connectors.sql
T

50 lines
1.8 KiB
SQL

-- +goose Up
CREATE SCHEMA connectors;
CREATE TABLE connectors.accepted (
org_id text NOT NULL,
name text NOT NULL,
path text NOT NULL,
sha256 text NOT NULL,
egress jsonb NOT NULL DEFAULT '[]',
env jsonb NOT NULL DEFAULT '[]',
settings jsonb NOT NULL DEFAULT '{}',
updated_at timestamptz NOT NULL DEFAULT now(),
contract text NOT NULL DEFAULT 'connector' CHECK (contract IN ('connector', 'secretengine', 'mcp', 'guard')),
credentials jsonb NOT NULL DEFAULT '{}',
args jsonb NOT NULL DEFAULT '[]',
url text NOT NULL DEFAULT '',
tools jsonb NOT NULL DEFAULT '[]',
capabilities jsonb,
effects jsonb,
enabled boolean NOT NULL DEFAULT true,
package jsonb,
PRIMARY KEY (org_id, name)
);
-- A credential's fields are sealed with age. Each field holds a value or the
-- secret engine key the value is read from.
CREATE TABLE connectors.credentials (
org_id text NOT NULL,
name text NOT NULL,
kind text NOT NULL CHECK (kind IN ('machine', 'age', 'basic', 'bearer')),
sealed bytea NOT NULL,
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (org_id, name)
);
-- The location of an organisation's extension catalogue and the public key that
-- verifies its signature.
-- newest_issued_at is the issue time of the newest catalogue accepted from it,
-- so an older catalogue replayed by the source or the network is refused.
CREATE TABLE connectors.catalogue_source (
org_id text PRIMARY KEY,
location text NOT NULL,
public_key text NOT NULL,
newest_issued_at timestamptz,
updated_at timestamptz NOT NULL DEFAULT now()
);
-- +goose Down
DROP SCHEMA connectors CASCADE;