Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DbUp should allow a special-case initial transition to create a database #16

Open
jez9999 opened this issue Feb 17, 2023 · 1 comment
Open
Labels
enhancement New feature or request
Milestone

Comments

@jez9999
Copy link

jez9999 commented Feb 17, 2023

I know you can use EnsureDatabase.For.SqlDatabase() to get DbUp to create a database if it doesn't exist, but I'd rather script it myself (along with the initial config changes to the database). In order to have a truly full history of DB transitions, there should be a special-case initial one that actually creates the DB.

I think DbUp needs to have a feature added to it to allow this because right now if you connect to the DBMS in order to create the DB you'll have to avoid specifying an initial catalog. As such, DbUp will create the SchemaVersions table in the master DB instead of in the one you've newly-created in the initial update script.

Perhaps DbUp could have a config setting allowing the first script to switch to a newly-created DB after the update is run, and only then create the SchemaVersions table?

@jez9999
Copy link
Author

jez9999 commented Feb 18, 2023

I've made a pull request with my proposed fix for this - allow an optional set of create database SQL statements to be passed into EnsureDatabase.For.SqlDatabase() and used instead of the one that's generated by DbUp. I also added the ability to check whether the DB would be created, in case the calling code wants to merely check whether a DB would be created without creating it (a 'validate migrations' kind of mode).

@droyad droyad transferred this issue from DbUp/DbUp Mar 15, 2024
@droyad droyad added this to the 6.0.0 milestone Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: v6
Development

No branches or pull requests

2 participants