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?
source to share
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)
source to share
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.
source to share
In version 4.0, you can disable cleaning by setting the cleanDisabled flag.
In pom
<cleanDisabled>false</cleanDisabled>
source to share