documentation/Reference/Configuration/Environments Namespace/Environment Provisioner Setting/Create Database Provisioner.md
{% include enterprise.html %}
This provisioner provisions and re-provisions a databases by creating it if necessary.
Benefits of using the create-database provisioner:
The following database engines are currently supported:
create-database.Note: The user account specified for the environment will need the required permissions to create a database, otherwise Flyway will exit with an error when it attempts to create the database.
Below we consider configuration and examples for each supported database engine types.
[environments.shadow]
url = "jdbc:sqlserver://localhost:1433;databaseName=MyDatabase;trustServerCertificate=true"
user = "MyUser"
password = "${localSecret.MyPasswordKey}"
provisioner = "create-database"
This example will create the database, named MyDatabase, if it does not exist when Flyway connects to the database
server. The create-database provisioner uses the databaseName parameter from the JDBC URL to determine the database to
create.
[environments.shadow]
url = "jdbc:postgresql://localhost:5430/my_database?ssl=true"
user = "MyUser"
password = "${localSecret.MyPasswordKey}"
provisioner = "create-database"
This example will create the database, named my_database, if it does not exist when Flyway connects to the database
server. The create-database provisioner extracts the database name from the JDBC URL to determine the database to
create.
[environments.shadow]
url = "jdbc:mysql://localhost:3306/my_database?useSSL=false"
user = "MyUser"
password = "${localSecret.MyPasswordKey}"
provisioner = "create-database"
This example will create the database, named my_database, if it does not exist when Flyway connects to the database
server. The create-database provisioner extracts the database name from the JDBC URL to determine the database to
create.
reprovisionMethod OptionThe create-database provisioner supports a reprovisionMethod parameter which controls how the specified database should be cleaned if it already exists when re-provisioned.
For example, if the create-database provisioner is configured with a URL containing the database name TestDatabase,
and that database already exists, then upon re-provisioning the TestDatabase would be cleaned in the method of your choice.
The example configuration below shows how to configure the NONE option for the shadow environment to prevent it from being re-provisioned:
[environments.shadow.resolvers.create-database]
reprovisionMethod = "NONE"