Disable automatic Database Migrations

Currently, at startup, Ghost checks to see what the database version should be running. When Ghost knows that it needs to upgrade, it performs an automatic database migration.

This strange behavior can cause some serious problems, such as accidentally migrating the production database by mistake.

For this reason, I want to suggest some way to disable this behavior and start discussing about changing the default behavior.

If you’ve upgraded Ghost to a new version that requires a database migration, those migrations are required for Ghost to function. This is why they run automatically - if they don’t you’re stuck with a Ghost install that won’t work.

We did, in Ghost 1.0, experiment with having these managed by Ghost-CLI instead of executed in the bootup, but that just caused more problems, so we reverted the behaviour back.

If you don’t like them running as part of the startup, then your current alternative is to manually run them, which you can do by stopping Ghost before running ghost update and then calling knex-migrator yourself, something like: ./current/node_modules/knex-migrator/bin/knex-migrator migrate --mgpath=./current.

Ghost won’t be able to serve anything during this time, so you’ll need to manage that.

Thanks for your reply,

I understand that there are several cases that automatic behavior is good, especially when the migration goes smoothly. But the discussion I want to raise is that automatic migration can also cause problems and lead to data loss.

The behavior I am suggesting would be like a warning when there is a need for a migration, or having a flag enabling this behavior.

We did, in Ghost 1.0, experiment with having these managed by Ghost-CLI instead of executed in the bootup, but that just caused more problems, so we reverted the behaviour back.

Sorry, but I couldn’t find this thread. Could you share this link with me?

It sounds like the underlying problem here is some sort of data loss incident, that should not have happened.

Can you share more details?