Ali Ahsan
Ali Ahsan

Reputation: 11

Is there a way to create postgres database before it executes changesets in liquibase

I am using liquibase in my spring boot app and I'm looking for a way to create a database before it executes the changesets.

Upvotes: 0

Views: 86

Answers (2)

Guillaume Georges
Guillaume Georges

Reputation: 4020

Depending on the database driver you're using, you might be able to create if it doesn't exist.

For instance, if you're using jdbc, you may add ?createDatabaseIfNotExist=true in your database url to make it create the database if it doesn't exist.

Full URL :

jdbc:mariadb://localhost:3306/databaseName?createDatabaseIfNotExist=true

Upvotes: 0

SteveDonie
SteveDonie

Reputation: 9016

Actually creating a database is one thing that Liquibase cannot do. It expects that the database you want to manage has already been created. Depending on the database platform you are using, it might be possible to connect to the same server that you want to create the database on and then issue SQL commands to create a new database, but that is one area where database servers differ greatly.

Upvotes: 1

Related Questions