feat: add durable dataset version store

This commit is contained in:
2026-09-07 18:00:58 +02:00
parent ea02f4e9f7
commit 298c965448
+26
View File
@@ -0,0 +1,26 @@
-- Durable canonical metadata for 0pt dataset versions.
-- Bytes remain canonical ST0RE artifacts referenced by artifact_refs.
CREATE TABLE IF NOT EXISTS opt_dataset_versions (
dataset_id text NOT NULL REFERENCES opt_datasets(dataset_id) ON DELETE RESTRICT,
version integer NOT NULL CHECK (version > 0),
tenant_id text NOT NULL,
project_id text NOT NULL,
artifact_refs text[] NOT NULL CHECK (cardinality(artifact_refs) > 0),
schema_version text NOT NULL,
record_count bigint CHECK (record_count IS NULL OR record_count >= 0),
description text,
created_at timestamptz NOT NULL DEFAULT now(),
created_by text NOT NULL,
correlation_id text,
idempotency_key text,
PRIMARY KEY (dataset_id, version),
CONSTRAINT opt_dataset_versions_idempotency
UNIQUE NULLS NOT DISTINCT (tenant_id, idempotency_key)
);
CREATE INDEX IF NOT EXISTS opt_dataset_versions_tenant_dataset_idx
ON opt_dataset_versions (tenant_id, dataset_id, version DESC);
COMMENT ON TABLE opt_dataset_versions IS
'Immutable 0pt dataset-version metadata. Content bytes remain in ST0RE artifacts.';