migrations
migrations copied to clipboard
Feature request: preventing "migrate down" command
"migrate down" is useful in development, but it can be catastrophic in production. It would be nice to prevent "down" part of the migration scripts on production servers (by using some bool property).
There is a simple-enough solution using a hook.
Create a hook script 'fail.js' in $MIGRATIONS_HOME/hooks directory with some invalid content. For example...
>>> This hook script saves you from making a critical mistake ;D
And specify the script as a before-down hook in your production.properties.
hook_before_down=js:fail.js
Now, migrate down against production never succeeds.
------------------------------------------------------------------------
-- MyBatis Migrations - down
------------------------------------------------------------------------
========== Applying JSR-223 hook : fail.js =====================================
------------------------------------------------------------------------
-- MyBatis Migrations FAILURE
-- Total time: 0s
-- Finished at: Sat May 20 02:57:18 JST 2017
-- Final Memory: 35M/479M
------------------------------------------------------------------------
ERROR: Error undoing last migration. Cause: javax.script.ScriptException: <eval>:17:0 Expected an operand but found >>>
>>> This hook script saves you from making a critical mistake ;D
^ in <eval> at line number 17 at column number 0
Please see the doc for the details about hooks.
closing as noted how to address.