VS2010 Deployment of a database project, for failure, if data loss can occur or not?

I have a database project for a web application and am currently set to crash if data loss can occur during deployment. I feel safer. However, I ran into a problem. I really need to deploy the changes in some cases, when I'm in order with a possible data loss, i.e. Shortens the lengths of the columns where nothing will actually be deleted, but the system thinks it will.

I have 2 questions.

Firstly, this: in addition to turning the catch on or off, everything goes or not, is there a way to have more detailed control over this process, i.e. Specify columns that can be omitted or reduced? Is there a way to get more granular control over this process?

Secondly, how do you guys deal with these situations? Initially, I was hoping that adding a pre-deploy script to remove the columns would be sufficient, however it seems like they also fall in drops, etc. In these files.

+6
source share
3 answers
  • No, there is no way to control this in more detail, unfortunately.
  • I will turn it off when I know that I will deploy something that will result in data loss, but this is what I want. Then I turn it on again. In addition, I will always check the script change that appears when deployed to production.
+2
source

Just update the column in the pre-deployment script to the truncation length?

For example: truncate my column to 20:

UPDATE mycol = LEFT(mycol, 20) FROM mytable WHERE mycol != LEFT(mycol, 20) 
0
source

Microsoft's guide is to move data to a temporary table in a pre-deployment, let the deployment engine check to see if the table contains rows (this will pass because it is now empty) and update the schema, and move the data back to the post- deployment script.

See Barclay Hills related articles for more information:

0
source

Source: https://habr.com/ru/post/886002/


All Articles