gitgram/aitimemachine/api-server/drizzle/0007_add_a2a_tables.sql
caelum0x 64fbe9f474 feat: round-3 deep product build-out (69 gaps closed, all 7 products green)
Deep-audit + build-out across all products to fully-usable state; all typecheck clean.

- gitgram-web (99): wire Store feature to real endpoints, close 9 gaps
- gitgram-backend (100): close 8 flow gaps, document infra-provisioning items
- gitgram-mobile (90): fix API base-URL/path mismatch (404s) + copy proximity
  components into components/proximity wired to real screens; 15 gaps, +react-native-svg
- aitm-core (95): wire natural-language CLI flow end-to-end; 11 gaps
- aitm-api (97): fix teams metadata runtime bug; copy a2a-js server/client/grpc
  into src/a2a and wire A2A route; crates.io package search; 8 gaps
- aitm-mcp (100): fix A2A client/server card mismatch; 9 gaps
- aitm-website (95): build missing docs routes; 9 gaps

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 13:54:57 +03:00

36 lines
1.4 KiB
SQL

-- Migration: add `a2a_agents` and `a2a_messages` for durable Agent-to-Agent state
-- Source: api-server A2AService DB-backing (services/a2aService.ts)
-- Notes:
-- - Replaces the previous in-memory agent registry + message inbox so
-- registered agents, their API keys, and queued/broadcast messages survive
-- restarts and are shared across horizontally-scaled instances.
-- - Additive + idempotent (CREATE TABLE/INDEX IF NOT EXISTS).
CREATE TABLE IF NOT EXISTS a2a_agents (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
capabilities TEXT[] NOT NULL DEFAULT '{}',
endpoint TEXT,
api_key TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'active',
registered_at TIMESTAMP NOT NULL DEFAULT now(),
last_seen TIMESTAMP NOT NULL DEFAULT now(),
CONSTRAINT a2a_agents_api_key_unique UNIQUE (api_key)
);
CREATE INDEX IF NOT EXISTS idx_a2a_agents_api_key ON a2a_agents (api_key);
CREATE INDEX IF NOT EXISTS idx_a2a_agents_status ON a2a_agents (status);
CREATE TABLE IF NOT EXISTS a2a_messages (
id TEXT PRIMARY KEY,
from_agent_id TEXT NOT NULL,
to_agent_id TEXT NOT NULL,
message_type TEXT NOT NULL,
payload JSONB NOT NULL,
session_id TEXT,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_a2a_messages_to_agent ON a2a_messages (to_agent_id);
CREATE INDEX IF NOT EXISTS idx_a2a_messages_to_agent_created ON a2a_messages (to_agent_id, created_at);