How to test if DACPAC can be deployed without actual deployment

Viewed 687

Is it possible to test a DACPAC against the DB without deploying it? sqlpackage.exe with Action=Deploy will deploy it if no errors are found and Action=Report will just generate a report with the list of changes but deployment can still fail.

1 Answers

Documentation says:

The SqlPackage.exe publish operation incrementally updates the schema of a target database to match the structure of a source database.

So, the success of the operation depends on current state of database to be updated. For example, the DAC package defines following table:

table MyTable (
    X int not null
);

while current definition of the table is

table MyTable (
    X int null
);

If the column X doesn't contain nulls the deployment will be succeed, and it will fail otherwise. So, there are several ways to check the deployment before publishing to production.

  1. Use Script action to create a script that updates the schema of a target to match the schema of a source. Afterwards you could analyze the script to find out possible fails during real deployment.
  2. Use test environment. You could also copy the production database using backup or BACPAC file and use it as a deployment target.
Related