You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I see you have functionality to create the Sql Server database if it doesn't exists. This is described in Issue 74
My request is not only valid for Sql Server although that's the database I'm using at the moment.
Why I need this? I'm introducing DbUp to a project that already existed. My goal is to be able to run the migrations in a machine without even the database and have everything created (same effect as if this project were using DbUp from the beginning).
The problem I'm facing is that because the database will already start in a given state I need to execute a baseline script upon database creation (this should be only execute once) and I don't find a way to do this with the current functionality in DbUp.
You can think you can add the first migration as this baseline script. That could be a possible solution, but serious attention has to be pay to the way that script is written, because the baseline script can be executed in databases that contain all the structures the script is trying to add, remember that is not just structure but also data.
I think that even when this is achievable with the current functionality, having something like this will be really useful.
var upgrader =
DeployChanges.To
.SqlDatabase(connectionString)
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly())
.WithBaselineScript("[Name of the Baseline script]") // <---- suggested addition
.LogToConsole()
.Build();
...
EnsureDatabase.For.SqlDatabase(connectionString, applyBaseline: true ); // <---- new parameter, not even necessary, because the builder definition can be enough.
Any thoughts??
Thanks,
Erlis
The text was updated successfully, but these errors were encountered:
Do you mean that when running DbUp the baseline script would be run when working from a non existant DB (i.e.: when EnsureDatabase kicks in) ?
In this case, shouldn't the .withBaselineScript directive be added to the EnsureDatabase rather than the upgrader? This way, the upgrader does not need to know whether the EnsureDatabase kicked in or not
Well, what I just explained was just an idea on how to do it. I think you guys will have more insight on how to do it. But I think you are absolutely right, EnsureDatabase is the one that should apply the baseline, is more cohesive this way.
You can do this by adding a line to the start of the first script(s) to check whether the structures already exist, and if so, return from the script. DBup will then create the schemaversions table and add a record for the script.
Hi I see you have functionality to create the Sql Server database if it doesn't exists. This is described in Issue 74
My request is not only valid for Sql Server although that's the database I'm using at the moment.
Why I need this? I'm introducing DbUp to a project that already existed. My goal is to be able to run the migrations in a machine without even the database and have everything created (same effect as if this project were using DbUp from the beginning).
The problem I'm facing is that because the database will already start in a given state I need to execute a baseline script upon database creation (this should be only execute once) and I don't find a way to do this with the current functionality in DbUp.
You can think you can add the first migration as this baseline script. That could be a possible solution, but serious attention has to be pay to the way that script is written, because the baseline script can be executed in databases that contain all the structures the script is trying to add, remember that is not just structure but also data.
I think that even when this is achievable with the current functionality, having something like this will be really useful.
Any thoughts??
Thanks,
Erlis
The text was updated successfully, but these errors were encountered: