sqlsql-serverredgatereadyroll

ReadyRoll Project: SemVer Option


I am trying to use ReadyRoll project for automated deployments. the previous project that I created had the following IF TYPE_ID(N'[dbo].[abc_PrintType]') IS NULL, in the first migration script that was generated after importing the database. I want to know which option to check in the properties of the project to generate the same line of code,

GO
PRINT N'Print types'
GO
IF TYPE_ID(N'[dbo].[abc_PrintType]') IS NULL
CREATE TYPE [dbo].[abc_PrintType] AS TABLE
(...)

Solution

  • The option you're looking for is Add object existence checks.

    This can be enabled in your project by adding the following code under the <Project> node within the .sqlproj file:

    <PropertyGroup> <!-- "Add object existence checks" SQL Compare option --> <SyncOptionIncludeExistenceChecks>True</SyncOptionIncludeExistenceChecks> </PropertyGroup>

    The next time you import a change, the generated script will include the IF EXISTS... style guard clauses.

    More information on how to configure this can be found in the ReadyRoll documentation: https://documentation.red-gate.com/pages/viewpage.action?pageId=42539778