Skip to content

fix(schema): remove three trigram index declarations that were already dropped#1409

Open
jakebromberg wants to merge 1 commit into
mainfrom
fix/1129-schema-trigram-drift
Open

fix(schema): remove three trigram index declarations that were already dropped#1409
jakebromberg wants to merge 1 commit into
mainfrom
fix/1129-schema-trigram-drift

Conversation

@jakebromberg

Copy link
Copy Markdown
Member

Summary

shared/database/src/schema.ts declared three GIN trigram indexes — auth_user_dj_name_trgm_idx, auth_user_name_trgm_idx, and shows_legacy_dj_name_trgm_idx — that migrations 0054 and 0065 explicitly DROP INDEX-ed. Because drizzle-kit treats schema.ts as the source of truth, every snapshot since 0055 kept carrying the entries forward — a fresh dev/test DB rebuilt from the schema would recreate the dead-weight indexes, and a future drizzle:generate against an aligned dev DB would emit a noisy catch-up migration.

Search no longer joins through auth_user or shows for dj-name lookup; reads come from flowsheet.dj_name + flowsheet_dj_name_trgm_idx.

Changes

  • Removed the three index(...) declarations from schema.ts (with breadcrumb comments explaining why).
  • Added 0094_drop-stale-trigram-indexes.sql catch-up migration with DROP INDEX IF EXISTS for each (no-op against environments that already applied 0054/0065).
  • Updated meta/0094_snapshot.json + journal + applied-hashes.json (drizzle-kit-generated; journal when bumped to previous + 1ms per the hand-edit-when rule).
  • Added tests/unit/database/schema.dropped-trigram-indexes.test.ts drift-prevention guard so a future edit can't reintroduce the declarations.

Test plan

  • npm run lint
  • npm run format:check
  • npm run typecheck
  • npm run test:unit (3155 tests pass)
  • npm run lint:migrations (validator clean)
  • New drift-prevention test covers all three index names and the latest snapshot.

Closes #1129

…y dropped (#1129)

`shared/database/src/schema.ts` declared three GIN trigram indexes
(`auth_user_dj_name_trgm_idx`, `auth_user_name_trgm_idx`,
`shows_legacy_dj_name_trgm_idx`) that migrations 0054 and 0065 explicitly
dropped. Because drizzle-kit treats `schema.ts` as the source of truth,
the cumulative snapshot kept carrying the entries forward — a fresh
dev/test DB would recreate the dead-weight indexes, and a future
`drizzle:generate` against an aligned dev DB would emit a noisy
catch-up migration.

- Remove the three `index(...)` declarations from `schema.ts`.
- Add 0094 catch-up migration with `DROP INDEX IF EXISTS` for each
  (no-op against environments that already applied 0054/0065).
- Update `meta/0094_snapshot.json` + journal + applied-hashes.json
  (drizzle-kit-generated; journal `when` bumped to
  previous + 1ms per the hand-edit-when rule).
- Add `schema.dropped-trigram-indexes.test.ts` drift-prevention guard.

Search reads from `flowsheet.dj_name` + `flowsheet_dj_name_trgm_idx`;
no query path joins through `auth_user` or `shows` for dj-name
trigram lookup.

Closes #1129
@github-actions

Copy link
Copy Markdown

Schema constraint shape report

data-shape report errored (exit 0): node:internal/modules/runmain:107 triggerUncaughtException( ^ Error ERRMODULENOTFOUND: Cannot find package 'postgres' imported from /home/runner/work/Backend-Service/Backend-Service/scripts/schema-shape-report.mjs Did you mean to import "postgres/cjs/src/index.js"? at Object.getPackageJ; manual check required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

schema.ts declares three dropped trigram indexes; next generate will recreate

1 participant