fix: scope dataset version idempotency uniqueness to real keys
This commit is contained in:
@@ -14,11 +14,13 @@ CREATE TABLE IF NOT EXISTS opt_dataset_versions (
|
||||
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)
|
||||
PRIMARY KEY (dataset_id, version)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS opt_dataset_versions_idempotency_idx
|
||||
ON opt_dataset_versions (tenant_id, idempotency_key)
|
||||
WHERE idempotency_key IS NOT NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS opt_dataset_versions_tenant_dataset_idx
|
||||
ON opt_dataset_versions (tenant_id, dataset_id, version DESC);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user