Working on a site with a staging environment. a quick question, is there a way to roll back a database change to previous import for testing purposes.

eg. i test something on local which alters the database, i push files and other non db relevant changes to staging, i change db on staging to accommodate local changes, i find there's some issues on staging with the db changes?

how would be able to rollback or undo database changes on staging?

1 Answer 1


Slightly confusing question. Unless you are employing a migrations tracking tool like Phinx, you are left to your own devices. As for DB migrations with EE, there isn't any easily deployable tools for us. It's slightly annoying. Here is a general workflow:

  1. Test on local developer instance of site making code and database schema changes.
  2. Make schema changes to target (staging or production) server, then push code.
  3. If reversion is required, rollback your deployed branch on target, and undo schema changes manually (delete Channel, delete Field Group, etc...)

The key to this system is to be additive until your current task is complete and in place, and only then should you remove any unused tables or columns. The idea is that if you have to develop a new iteration of an appliance already in place and in production, but it requires schema changes, simply add new columns/tables to accommodate your new iteration of this appliance. Then once it's complete, import your data from the old appliance tables into the new one, and then point all old references to the old appliance towards the new one. Then you can safely remove the old version's database columns / tables.

BUT, for the future... if you need to be extra careful between local and staging, simply export your target's database as a backup before making any schema changes. Then if it goes ary and you don't know what tables and columns and rows to manually remove, you can simply import your backup.

  • If you're using Git, you can use hooks to backup the database and store in your git repository, this can also be used to automatically refresh your local DB when you pull. There's various articles online, but here's a start: ben.kulbertis.org/2011/10/… Apr 5, 2016 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.