Flywaydb: How to Stop Accidental Cleaning

Inside Flyway Db there is a command called "clean" if we use it to leave all objects in the schematic.

Drops all objects (tables, views, procedures, triggers, ...) in the configured schemas. The schemas are flushed in the order specified by the schemas property.

How can we turn this off so that no one else uses it until they need it?

+3


source to share


4 answers


The best option from the command line is to wrap the Flyway script with your own. Then you can intercept the pure command and not use it.



+2


source


The easiest way to do this is to manage the privileges in your database and refuse to navigate to the hop user.



If you don't have a hand in the database configuration and using the java Api, you can write Aspect to throw an exception with the Around advisor in the following pointcut: "execute (public * org.flywaydb.core.Flyway.clean (..)" (not verified)

+1


source


jrf's comment is more helpful, adding this as an answer.

You may have a different flyway.conf file for a different environment and set flyway.cleanDisabled = true / false .

Use the flyway command with the config file parameter: example> flyway -configFile=path/to/myAlternativeConfig.conf clean



This should now allow you to have the separation and flexibility of using a clean. How can you enable cleanup in dev environment and disable it on prod.

0


source


In version 4.0, you can disable cleaning by setting the cleanDisabled flag.

In pom

 <cleanDisabled>false</cleanDisabled>

      

See https://flywaydb.org/documentation/maven/clean

https://github.com/flyway/flyway/issues/458

0


source







All Articles