Is there a project file setting to remove the server name check?
PeterDaniels
Posts: 89 Bronze 3
At my company, there is a large wall between dev and ops. Ops DBAs want a single SQL script to use in all of their environments (anything above dev and qa). So, I have been taking the TargetedDeploymentScript.sql and removing the check that requires a specific sever name, so it will execute on multiple severs. Yes,I realize this is non-ideal. I have a powershell script that does this.
Wondering if there is a property that I can set in the sqlproj file, or a cmdlet option that will remove it automatically?
TIA,
-Peter
Wondering if there is a property that I can set in the sqlproj file, or a cmdlet option that will remove it automatically?
TIA,
-Peter
Tagged:
Best Answers
-
Monday Posts: 77 Silver 3@PeterDaniels I don't get a TargetedDeploymentScript.sql at all. I get a PackageScript.sql in \db\output\
Here is how I am doing my build that produces a nuget package where PackageScript.sql is located.$temporaryDatabase = New-DatabaseConnection -ServerInstance $EAMDBServer -Database $PQTempDB$ProjectObject = $ProjectFile | Invoke-DatabaseBuild -TemporaryDatabase $temporaryDatabase$DBDeployFile = $ProjectObject | New-DatabaseBuildArtifact -PackageId EAMDatabase -PackageVersion $PackageVersion$DBDeployFile | Export-DatabaseBuildArtifact -Path $CopyLocation -
PeterDaniels Posts: 89 Bronze 3Thank you, @Monday. It took me a while to find time to dig into this. I had never looked into the actual files within the nupkg file. Now, thanks to you, I do see the db\output\PackageScript.sql. I also see how it has ALL of the migrations including baseline and will intelligently apply them to whatever DB I set in the sqlcmd var DatabaseName.
There are a couple of issues with this file (in its raw form) that I will need to resolve to be able to pass it to the ops DBAs so they can execute in SSMS via SQLCMD mode:
1) I'll need to uncomment the sqlcmd vars section
2) I'll need to manually set the ReleaseVersion and PackageVersion. Not sure why the PackageVersion isn't set by New-DatabaseBuildArtifact cmdlet since we are passing that in.
Probably a lil powershell will take care of the above concerns, but it would be nice to have options during build to extract this file with these taken care of.
UPDATE: I am also able to get the PackageScript.sq content from the PackageScript property of the BuildArtifact object returned from Invoke-DatabaseBuild. This way I can skip the Export-DatabaseBuild step, and just save this to a file and process it.
Answers
I hope this helps.
I'm asking if there is a setting in the project file that I can use to have it not include that check so I don't have to edit it each time?
Example of the generated code I remove:
My PoSh function to remove it:
And using it with the file:
I hope this helps.
I hope this helps.