Skip to content
Latchkey

flyway clean: Drop All Objects (Use With Care)

flyway clean drops all tables, views, and other objects in the schemas Flyway manages, returning them to empty.

clean is useful to reset a throwaway test database between runs. It is destructive, so Flyway ships with it disabled by default in newer versions.

What it does

flyway clean removes every database object in the configured schemas, including the schema history table. The next migrate then rebuilds the schema from scratch. It deletes data, so it belongs only on ephemeral CI databases.

Common usage

Terminal
# reset an ephemeral test database, then rebuild
flyway -url=jdbc:postgresql://localhost:5432/test \
  -user=ci -password="$DB_PASSWORD" \
  -cleanDisabled=false clean

flyway migrate

Options

FlagWhat it does
-cleanDisabled=falseExplicitly allow clean (it is disabled by default)
-schemas=<list>Which schemas get cleaned
-cleanOnValidationErrorLegacy option to auto-clean on validation failure (avoid)
-url / -user / -passwordConnection details

In CI

Only ever run clean against a database created for the job, never a shared or production one. Recent Flyway versions require -cleanDisabled=false to run it at all, a guardrail added after production accidents. Prefer spinning up a fresh container over cleaning a persistent database.

Common errors in CI

"Unable to execute clean as it has been disabled with the 'flyway.cleanDisabled' property" is the safety block; set -cleanDisabled=false only if the target is disposable. "Unable to clean unknown schema" means -schemas names a schema that does not exist.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →