Blog Post

Deployment Contributor KeepTableColumns Filter

,

To help with this scenario (it is pretty specific):

You have a table that has columns that you do not know about when you create the dacpac, possibly you have a customer who modifies your schema after you deploy. If you deploy your dacpac those columns will be dropped which is bad and you don't want to completely ignore all changes to a table what do you do?

You can now use the new version of my deployment contributor with a filter like SqlPackageFilter=KeepTableColumns(Employees)

This stops the DacFx from dropping any columns on Employees or rebuilding the Employees table which would cause an implicit drop of the table.

There are some things to know about this:

  • 1. This will stop ALTER TABLE DROP COLUMN statements
  • 2. It won't drop ALTER TABLE ADD COLUMN statements
  • 3. If you try to do something that would cause a table rebuild that is cancelled
  • 4. I have made some assumptions about the code which I am fairly sure about but it is undocumented so there is an additional risk

What I would suggest is actually what I suggest anyway, use the same dacpac for different environments and use the same processes and test your deployment scripts before releasing to production / customers.

If you have any questions or any issues please shout!

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating