fix(catalog-backend): scope pg_class lookups to relkind='i' in migration helpers

Prevents a false match if any non-index object (table, sequence, view)
shares a name with one of the search indices.

Signed-off-by: Fredrik Adelöw <freben@spotify.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Fredrik Adelöw
2026-05-11 13:42:06 +02:00
parent 63036124cc
commit f503fc935b
@@ -188,7 +188,7 @@ async function ensurePgIndex(knex, opts) {
SELECT indisunique, indisvalid
FROM pg_index
WHERE indexrelid = (
SELECT oid FROM pg_class WHERE relname = ?
SELECT oid FROM pg_class WHERE relname = ? AND relkind = 'i'
)
`,
[name],
@@ -217,7 +217,7 @@ async function ensurePgIndex(knex, opts) {
async function dropPgIndexIfExists(knex, name) {
const result = await knex.raw(
`
SELECT 1 FROM pg_class WHERE relname = ?
SELECT 1 FROM pg_class WHERE relname = ? AND relkind = 'i'
`,
[name],
);