Files
yakpanel-core/architecture/2026/14-server-plane-schema-additions.sql

31 lines
1.2 KiB
MySQL
Raw Normal View History

2026-04-07 20:29:49 +05:30
-- Optional server-plane extension tables
CREATE TABLE IF NOT EXISTS command_dispatches (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
tenant_id uuid NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
job_id uuid NOT NULL REFERENCES jobs(id) ON DELETE CASCADE,
server_id uuid NOT NULL REFERENCES servers(id) ON DELETE CASCADE,
command_type varchar(64) NOT NULL,
idempotency_key varchar(120) NOT NULL,
status varchar(32) NOT NULL DEFAULT 'queued',
queued_at timestamptz NOT NULL DEFAULT now(),
dispatched_at timestamptz NULL,
acked_at timestamptz NULL,
finished_at timestamptz NULL,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (tenant_id, idempotency_key)
);
CREATE TABLE IF NOT EXISTS agent_heartbeats (
id bigserial PRIMARY KEY,
tenant_id uuid NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
server_id uuid NOT NULL REFERENCES servers(id) ON DELETE CASCADE,
agent_uid varchar(128) NOT NULL,
payload jsonb NOT NULL DEFAULT '{}'::jsonb,
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_agent_heartbeats_server_created
ON agent_heartbeats (server_id, created_at DESC);