Files
backstage/.changeset/fix-alter-target-nullability.md
T
Fredrik Adelöw b33f8450b5 fix(catalog-backend): fix irreversible database migration down functions
Five migration down functions were broken, causing the SQL report to flag
them as not reversible. All issues were pre-existing bugs that were never
caught because the down migrations had never been exercised under the
reversibility checker.

- 20241003170511: add .notNullable() to both up and down when altering
  locations.target, preventing the NOT NULL constraint from being silently
  dropped by knex's .alter() when widening varchar(255) to text.
- 20220116144621: implement a real down function that recreates the three
  dropped legacy tables (entities, entities_search, entities_relations)
  with correct columns and indices.
- 20210302150147: drop dependent tables in the correct order to avoid a
  FK constraint violation, and fix a typo (references → refresh_state_references).
- 20201005122705: drop full_name from entities (not entities_search), and
  restore entities_unique_name with the correct column order (kind, name, namespace).
- 20200702153613: use table.integer('generation') instead of table.string()
  in the down function to restore the correct column type.

Signed-off-by: Fredrik Adelöw <freben@spotify.com>
Made-with: Cursor
2026-04-14 14:54:42 +02:00

1.3 KiB

@backstage/plugin-catalog-backend
@backstage/plugin-catalog-backend
patch

Fixed several database migration down functions that were not properly reversible, causing the SQL report to show warnings:

  • 20241003170511_alter_target_in_locations.js: both up and down now include .notNullable() when altering the locations.target column, preventing the NOT NULL constraint from being accidentally dropped when widening the column type from varchar(255) to text.
  • 20220116144621_remove_legacy.js: the down function now properly recreates the three dropped legacy tables (entities, entities_search, entities_relations) with correct columns and indices.
  • 20210302150147_refresh_state.js: the down function now drops dependent tables in the correct order (avoiding a FK constraint violation) and fixes a typo where the table was referred to as references instead of refresh_state_references.
  • 20201005122705_add_entity_full_name.js: the down function now drops the full_name column from entities (not entities_search), and restores the entities_unique_name index with the correct column order (kind, name, namespace).
  • 20200702153613_entities.js: the down function now uses table.integer('generation') instead of table.string('generation'), restoring the correct column type.