-- 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') ); COMMENT ON TABLE opt_search_index_definitions IS 'Versioned logical 0pt search schemas. OpenSearch indices remain disposable projections.';