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:
@@ -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],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user