As this is environment specific, I would suggest you to choose one of the below approaches:
You can have three approaches:
- As @Lukasz Szozda suggested, you can have SQLCMD variable. Define SQLCMD variable and mention the environment. Based on environment, you can decide which script to execute in your post deployment script.
IF '$(Environment)' = 'Prod'
BEGIN
:r .\ProdSpecificScript\Prod_TableTable.sql
END
ELSE
BEGIN
:r .\NonProdSpecificScript\NonProd_TableTable.sql
END
- You can update Project file with below information, to overwrite Postdeployment script with different file, based on the environment. You can have two different post deployment scripts with different TableType script.
<Target Name="BeforeBuild">
<Message Text="Copy files task running for configuration: $(Configuration)" Importance="high" />
<Copy Condition=" '$(Environment)' == 'Prod' " SourceFiles="Scripts\Post-Deployment\Default.Script.PostDeployment.sql" DestinationFiles="Scripts\Post-Deployment\Script.PostDeployment.sql" OverwriteReadOnlyFiles="true" />
<Copy Condition=" '$(Environment)' == 'NonProd' " SourceFiles="Scripts\Post-Deployment\Default.Script.PostDeployment.sql" DestinationFiles="Scripts\Post-Deployment\Script.PostDeployment.sql" OverwriteReadOnlyFiles="true" />
</Target>
- You can check Azure Service tier and accordingly decide the script.
DECLARE @ServiceTier VARCHAR(30)
SET @ServiceTier = (SELECT COALESCE(DATABASEPROPERTYEX(DB_NAME(), 'ServiceObjective'), 'N/A in v11') AS AzureTier FROM sys.database_service_objectives
IF @ServiceTier = 'P1'
BEGIN
:r .\ProdSpecificScript\Prod_TableTable.sql
END
ELSE
BEGIN
:r .\NonProdSpecificScript\NonProd_TableTable.sql
END