remora/crates/remora-worker/migrations/0001_descriptors.sql

14 lines
608 B
SQL

CREATE TABLE worker_descriptors (
descriptor_id TEXT PRIMARY KEY,
attempt_id TEXT NOT NULL REFERENCES attempts (attempt_id) ON DELETE CASCADE,
kind TEXT NOT NULL CHECK (kind IN ('resolved_source', 'checkpoint')),
schema_version INTEGER NOT NULL CHECK (schema_version >= 1),
payload JSONB NOT NULL,
byte_length BIGINT NOT NULL CHECK (byte_length >= 0),
item_count BIGINT CHECK (item_count >= 0),
checksum TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL
);
CREATE INDEX worker_descriptors_attempt_idx
ON worker_descriptors (attempt_id, kind, created_at, descriptor_id);