Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow (once) column drop in database project

I would like to drop one column in existing table. When I simply remove it from table's create script it will cause error (data loss...) on deployment. I would like to allow (in this case) column drop. How you would do that?

like image 315
adamdms Avatar asked Sep 26 '13 14:09

adamdms


2 Answers

To disable the data loss error:

  1. Click the Options icon in your schema comparison file.
  2. Uncheck "Block on possible data loss".

The setting will change for just that 1 schema comparison and it will be saved within the schema comparison file. If you only want to do this once then you'll need to re-enable the option after you drop the column.

like image 145
Keith Avatar answered Oct 11 '22 21:10

Keith


We did this by creating a PreDeployment script to drop the column. Reasoning is we do not want to allow data loss for all objects in the database.

You can create automated version checks to do this only once (see my answer to another post Nontrivial incremental change deployment with Visual Studio database projects for steps how to automate this with SSDT.)

Or you can just supply the script to devops and include instructions in your install manual to run it once for a specific release.

After the release has gone live, you can delete the PreDeployment script.

like image 2
S Koppenol Avatar answered Oct 11 '22 21:10

S Koppenol