MCPcopy Index your code
hub / github.com/simstudioai/sim / warnOnInvalidIndexes

Function warnOnInvalidIndexes

packages/db/scripts/migrate.ts:215–233  ·  view source on GitHub ↗

* A failed CONCURRENTLY build leaves an INVALID index that `IF NOT EXISTS` * silently skips forever — surface it (warn only; the migration committed).

()

Source from the content-addressed store, hash-verified

213 * silently skips forever — surface it (warn only; the migration committed).
214 */
215async function warnOnInvalidIndexes(): Promise<void> {
216 try {
217 const rows = await client`
218 SELECT n.nspname AS schema, c.relname AS index
219 FROM pg_index i
220 JOIN pg_class c ON c.oid = i.indexrelid
221 JOIN pg_namespace n ON n.oid = c.relnamespace
222 WHERE NOT i.indisvalid
223 `
224 for (const row of rows) {
225 console.warn(
226 `WARN: invalid index ${row.schema}.${row.index} — a CONCURRENTLY build failed partway. ` +
227 'Drop and rebuild it; IF NOT EXISTS will keep skipping it.'
228 )
229 }
230 } catch (checkError) {
231 console.warn('WARN: could not check for invalid indexes.', checkError)
232 }
233}
234
235/**
236 * Unlock errors are swallowed: the session lock auto-releases on disconnect,

Callers 1

migrate.tsFile · 0.85

Calls 1

warnMethod · 0.65

Tested by

no test coverage detected