Flyway SQL Server Clean Mode Setting
Published 15 January 2025
Description
This configures how the clean command works to enable Flyway to delete objects beyond the schemas specified in the schemas configuration option.
Valid values
default: The default behaviorschema: All database schemas will be cleaned, excluding built-in schemas.all: All database objects will be dropped, including all schemas
Objects dropped in all mode
XML Schema Collections(at the schema-level)Column encryption keysColumn master keysSymmetric keysEvent notificationsFulltext stoplistsRegistered search property listsApplication rolesandDatabase rolesthat aren't 'fixed roles' (built-in roles)
Interaction with schema parameter
- An error will be raised if
flyway.sqlserver.clean.modeis set toschemaorall, and schemas is also configured.- This is to prevent accidental deletion of schemas, as Clean Mode essentially overrides the behavior of schemas.
Excluding specific schemas
There is also a
flyway.sqlserver.clean.schemas.exclude parameter which takes an array of schemas to exclude.
These schemas won't be dropped or cleaned in schema or all mode.
Type
String
Default
default
Usage
Flyway Desktop
This can't be configured via Flyway Desktop, although it will be honoured.
TOML Configuration File
[flyway.sqlserver.clean]
mode = "all"
Configuration File
flyway.sqlserver.clean.mode=all
flyway.sqlserver.clean.schemas.exclude=schema1,schema2
Notes
- This is only available for SQL Server
- This is only available in the configuration file - no CLI, Maven, Gradle, etc
- When running clean, no users will be dropped to prevent unintended loss of connectivity. You can explicitly remove Users via a callback script.