Skip to content

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

Description

@jez9999

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?

Activity

  1. jez9999 commented on Feb 18, 2023

    @jez9999
    ContributorAuthor

    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).

  2. transferred this issue fromDbUp/DbUpon Mar 15, 2024
  3. added this to the 6.0.0 milestone on Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions