Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: preventing "migrate down" command #75

Closed
srdjan-mijatov opened this issue May 19, 2017 · 2 comments
Closed

Feature request: preventing "migrate down" command #75

srdjan-mijatov opened this issue May 19, 2017 · 2 comments
Assignees

Comments

@srdjan-mijatov
Copy link

"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).

@harawata
Copy link
Member

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.

@hazendaz
Copy link
Member

hazendaz commented May 7, 2023

closing as noted how to address.

@hazendaz hazendaz closed this as completed May 7, 2023
@hazendaz hazendaz self-assigned this May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants