none
with a Database project with schema and post deploys, is there a way to NOT run the post deploy scripts (like a option) RRS feed

  • Question

  • with a Database project with schema and post deploys, is there a way to NOT run the post deploy scripts (like a option).

    I have a database project that also has a couple dozen post deploy scripts that are setup to be applied.

    is there a way to deploy that database project without applying the post deploy data scripts?

    thanks

    Wednesday, November 13, 2019 8:14 PM

All replies

  • I went ahead and just created a separate solution/dbproj to handle schema only.

    I believe that having Schema and data in 2 different db projects is the way to go.

    Thursday, November 14, 2019 7:45 PM
  • Define a SQLCMD variable, i.e., $(DeployPostScript). You need to add the IF statement in those post scripts which may or may not run based on $(DeployPostScript) = 1 or 0

    IF $(DeployPostScript) = 1

    BEGIN
     -- Your Code
    END


    A Fan of SSIS, SSRS and SSAS





    • Edited by Guoxiong Thursday, November 14, 2019 8:34 PM
    • Proposed as answer by Olaf HelperMVP Friday, November 15, 2019 7:01 AM
    Thursday, November 14, 2019 8:26 PM
  • Your post deployment scripts must be re-runnable.  They are run every time you deploy the dacpac.

    So the simplest solution to your problem is to add some criteria to the post deploy script like:

    IF (SELECT COUNT(*) FROM tbl)=0 

    BEGIN

    -- Seed table

    END

    Else

    PRINT 'Table already populated.  No changes made'

    • Proposed as answer by Olaf HelperMVP Friday, November 15, 2019 7:01 AM
    Thursday, November 14, 2019 8:49 PM