Pre-Upgrade Validation

Once a database is deployed or registered, you can start applying changes to the database using DAC upgrades. Why would you use DAC upgrades versus standard script changes you ask?

  1. You don’t need to maintain script libraries, just DACPACs
  2. DACPACs are versioned so you can always tell what their relative ordering is
  3. When upgrading, the DAC registration is updated as well allowing you to always audit the database to see if anything has changed since the last official DACPAC deployment or upgrade.

Before you can actually perform a DAC upgrade, DACFx performs a few checks on the target database to help inform you prior to the upgrade. DACFx first checks to see if anything in the database has changed since the last DACPAC upgrade (or initial deployment) and presents these as database changes.

For an administrator or a developer who is trying to upgrade the database, knowing what’s changed since the last deployment is a nice piece of information because the developer may not have taken those changes into account and the changes could be lost as a part of the upgrade process. Let’s see what that looks like:

The second item that’s checked is whether the upgrade could potentially cause data loss. Remember that a DACPAC is a replete definition of a database so if you don’t have something defined in the DACPAC but it is defined in the database, we have to remove that item from the database in order to ensure the database mirrors the DACPAC.

As an example, let’s take a database that has two tables: T1 and T2. Then suppose we have a DACPAC that has only T1 defined inside it. If you were to upgrade the database, the upgrade script would drop T2 because T2 is not defined in the DACPAC.

We also warn on potential data loss when data types explicitly change because data could become truncated or otherwise lost. For example, if you were to change a column from BIGINT to INT you could potentially lose data. Let see what a data loss warning looks like:

Presuming there are no issues with database changes and data loss then you can proceed to perform the actual upgrade which is the subject of the next post.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: