feat: persist versioned search index definitions

This commit is contained in:
2026-09-07 18:07:45 +02:00
parent ccda286022
commit 1c1d14a3eb
+21
View File
@@ -0,0 +1,21 @@
-- Canonical 0pt search-index definitions. OpenSearch itself remains a
-- rebuildable projection; this table stores only the logical schema needed to
-- rebuild/query that projection after restart.
CREATE TABLE IF NOT EXISTS opt_search_index_definitions (
index_name text NOT NULL,
version integer NOT NULL CHECK (version > 0),
fields jsonb NOT NULL,
default_search_fields text[] NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
created_by text,
PRIMARY KEY (index_name, version),
CONSTRAINT opt_search_index_definitions_fields_object
CHECK (jsonb_typeof(fields) = 'object')
);
CREATE UNIQUE INDEX IF NOT EXISTS opt_search_index_definitions_one_active_version
ON opt_search_index_definitions (index_name, version);
COMMENT ON TABLE opt_search_index_definitions IS
'Versioned logical 0pt search schemas. OpenSearch indices remain disposable projections.';