backstage: Backend failed to start up, Error: The migration directory is corrupt, the following files are missing
Expected Behavior
The backend should start up successfully
Actual Behavior
An error occurs.
[1] Backend failed to start up, Error: The migration directory is corrupt, the following files are missing: 20200511113813_init.js, 20200520140700_location_update_log_table.js, 20200527114117_location_update_log_latest_view.js, 20200702153613_entities.js, 20200721115244_location_update_log_latest_deduplicate.js, 20200805163904_location_update_log_duplication_fix.js, 20200807120600_entitySearch.js, 20200809202832_add_bootstrap_location.js, 20200923104503_case_insensitivity.js, 20201005122705_add_entity_full_name.js, 20201006130744_entity_data_column.js, 20201006203131_entity_remove_redundant_columns.js, 20201007201501_index_entity_search.js, 20201019130742_add_relations_table.js, 20201123205611_relations_table_uniq.js, 20201210185851_fk_index.js, 20201230103504_update_log_varchar.js, 20210209121210_locations_fk_index.js, 20210302150147_refresh_state.js, 20210622104022_refresh_state_location_key.js, 20210813143113_add_refresh_state_hash.js, 20210925102509_add_refresh_state_input_hash.js, 20220116144621_remove_legacy.js, 20220222164811_reprocess_for_relation_refs.js
Steps to Reproduce
- Configure Postgres connection as such:
database:
# config options: https://node-postgres.com/api/client
client: pg
connection:
connectionString: 'postgres://backstage:secret@machinename/backstage'
# host: machinename
# port: 5432
# user: backstage
# database: 'backstage'
# password: secret
# https://node-postgres.com/features/ssl
ssl: # see https://www.postgresql.org/docs/current/libpq-ssl.html Table 33.1. SSL Mode Descriptions (e.g. require)
rejectUnauthorized: false
- Run yarn dev
- See error
Context
I’ve been trying to get my Backstage instance connected to a Postgres database for a few days now but I always end up back in this same spot.
Things I’ve tried:
- Clean install/redo the changes I need
- Deleted all node_modules folders and reinstalled
- Dropped and recreated all databases related to Backstage
- Manually removed rows from migrations table
Also, I am using the connectionString configuration property because I need to specify the maintenance database. We cannot get read/write access to the default postgres database per our account security policies, and the database configuration property is not adhered to it seems.
I found these files in the catalog-backend which appears to be exactly what the error message is pointing to.
Any help would be greatly appreciated!
Your Environment
Running Ubuntu 20
-
Browser Information: n/a
-
Output of
yarn backstage-cli info:
OS: Linux 5.4.0-107-generic - linux/x64
node: v16.15.0
yarn: 1.22.18
cli: 0.17.0 (installed)
Dependencies:
@backstage/app-defaults 1.0.1
@backstage/backend-common 0.13.2
@backstage/backend-tasks 0.3.0
@backstage/catalog-client 1.0.1
@backstage/catalog-model 1.0.1
@backstage/cli-common 0.1.8
@backstage/cli 0.17.0
@backstage/config-loader 1.1.0
@backstage/config 1.0.0
@backstage/core-app-api 1.0.1
@backstage/core-components 0.9.3
@backstage/core-plugin-api 1.0.1
@backstage/errors 1.0.0
@backstage/integration-react 1.0.1
@backstage/integration 1.1.0
@backstage/plugin-api-docs 0.8.4
@backstage/plugin-app-backend 0.3.31
@backstage/plugin-auth-backend 0.13.0
@backstage/plugin-auth-node 0.2.0
@backstage/plugin-azure-devops-backend 0.3.10
@backstage/plugin-azure-devops-common 0.2.2
@backstage/plugin-azure-devops 0.1.20
@backstage/plugin-catalog-backend-module-azure 0.1.2
@backstage/plugin-catalog-backend 1.1.1
@backstage/plugin-catalog-common 1.0.1
@backstage/plugin-catalog-graph 0.2.16
@backstage/plugin-catalog-import 0.8.7
@backstage/plugin-catalog-react 1.0.1
@backstage/plugin-catalog 1.1.0
@backstage/plugin-github-actions 0.5.4
@backstage/plugin-org 0.5.4
@backstage/plugin-permission-common 0.6.0
@backstage/plugin-permission-node 0.6.0
@backstage/plugin-permission-react 0.4.0
@backstage/plugin-proxy-backend 0.2.25
@backstage/plugin-scaffolder-backend 1.1.0
@backstage/plugin-scaffolder-common 1.0.1
@backstage/plugin-scaffolder 1.1.0
@backstage/plugin-search-backend-node 0.6.0
@backstage/plugin-search-backend 0.5.1
@backstage/plugin-search-common 0.3.3
@backstage/plugin-search-react 0.1.0
@backstage/plugin-search 0.8.0
@backstage/plugin-tech-radar 0.5.11
@backstage/plugin-techdocs-backend 1.1.0
@backstage/plugin-techdocs-node 1.1.0
@backstage/plugin-techdocs-react 0.1.0
@backstage/plugin-techdocs 1.1.0
@backstage/plugin-user-settings 0.4.3
@backstage/release-manifests 0.0.2
@backstage/search-common 0.3.3
@backstage/test-utils 1.0.1
@backstage/theme 0.2.15
@backstage/types 1.0.0
@backstage/version-bridge 1.0.1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (8 by maintainers)
Managed to fix the error, connected to the local db then went to backstage_plugin_catalog and then deleted the corrupt migrations from both knex_migrations and knex_migration_lock and that resolved the issue!
These were created recently when i tried upgrading to the lates version of backstage (1.9.3), I still don’t know what caused the creation of those, probably a package upgrade
@arhill05 I’m stuck on this issue. Can you please provide some more information. I’m currently have the following config:
I’m still running in the error:
Hi, could we have some help and guidance from the backstage team ? Looks like a lot of us are unable to make it work with heroku postgres databases.
Regards
Gotcha. Is there any easy way to find what plugins need databases/what databases they will create automatically so I can create them by hand?
I managed to get it working by setting the combination of the
backend.database.ensureExists: falseand thebackend.database.pluginDivisonMode: 'schema'configuration settings. It’d still be nice to have the maintenance database that is used when connecting to theadmindatabase in that code adhere to thedatabaseconfiguration property or the database specified in the connection string.Thanks for your help 😃
I can’t omit specifying a database due to security policies at my workplace - I can’t use the default
postgresdatabase for the maintenance database.Besides, I can see the plugin databases being created and populated, so I know that part is working. I’ve also tried both the
backend.database.pluginDivisionModeandbackend.database.ensureExistsconfiguration options to no avail.