Executing embedded migration not using SQLCMD variables
christianacca
Posts: 24 Bronze 1
I am running embedded migrations as per the help docs: https://documentation.red-gate.com/disp ... d+Resource
I'm finding that the SQLCMD variables that I've defined in my ReadyRoll project are not being used. Please don't say I have to reinvent the same mechanism that ReadyRoll would be doing for me?!?
I think I know the answer to that. So the next question is - can you provide a sample that I could use that would read the variables from the .sqlproj.user and then .sqlproj files to populate the SqlCmd.
Thanks
Christian
I'm finding that the SQLCMD variables that I've defined in my ReadyRoll project are not being used. Please don't say I have to reinvent the same mechanism that ReadyRoll would be doing for me?!?
I think I know the answer to that. So the next question is - can you provide a sample that I could use that would read the variables from the .sqlproj.user and then .sqlproj files to populate the SqlCmd.
Thanks
Christian
Comments
You're quite correct about that limitation, unfortunately. The embedded deployment functionality is still fairly new so we haven't got to filling that functionality gap just yet.
The variable values from the project are actually inserted into the header of the SQLCMD package file at build time, but commented out. If you'd like to use them, it's just a matter of "un-commenting" them in the script prior to deployment. Does that help at all?
Product Manager
Redgate Software
My action plan is therefore:
1. Use the commented out variables when running the embedded migrations on a developer machine
2. Create a custom section in the web config to read the variable values from for all other deployments (values will vary per environment)
As a side note, the open source tool used to execute the embedded migrations (https://www.nuget.org/packages/com.rusanu.DBUtil/) has a limitation which means the variables included in the header of the script fails to produce the correct variable substitution at runtime.
This is fixed in a fork of the DBUtil project's repo (https://github.com/AdamDee/com.rusanu.dbutil/pull/1), but this is not available on nuget. In the meantime, that means everyone who goes this route will need to cut their own nuget package from the source of the above pull request.
C
I'll follow up with the author of the DBUtil project in the next few days if there hasn't been a response to your comment on the PR.
Product Manager
Redgate Software
It just needs merging and a new nuget package cut and published from the merged source.
Can you ask the author to do this.
Thanks
Christian
Product Manager
Redgate Software
Please let me know how you get on.
Product Manager
Redgate Software
Product Manager
Redgate Software