如何删除VSTS DacpacTask中的列?

时间:2016-10-26 18:57:48

标签: azure azure-devops azure-pipelines-release-pipeline

我在VSTS中有一个生成.dacpac文件的构建步骤,我将其传递给Release定义,然后使用Execute Azure SQL:DacpacTask更新数据库。当我尝试删除列时,这是DacpacTask的输出:

2016-10-26T18:12:01.3300540Z ##[section]Starting: Execute Azure SQL : DacpacTask
2016-10-26T18:12:01.3674946Z ==============================================================================
2016-10-26T18:12:01.3674946Z Task         : Azure SQL Database Deployment
2016-10-26T18:12:01.3674946Z Description  : Deploy Azure SQL DB using DACPAC or run scripts using SQLCMD
2016-10-26T18:12:01.3674946Z Version      : 1.1.2
2016-10-26T18:12:01.3674946Z Author       : Microsoft Corporation
2016-10-26T18:12:01.3674946Z Help         : [More Information](https://aka.ms/sqlazuredeployreadme)
2016-10-26T18:12:01.3674946Z ==============================================================================
2016-10-26T18:12:04.8304591Z packageFile= C:\a\r1\a\MyProject\Database\Database.dacpac
2016-10-26T18:12:07.4389560Z Publishing to database 'MyDB' on server 'mydatabase.database.windows.net'.
2016-10-26T18:12:08.3318189Z Initializing deployment (Start)
2016-10-26T18:12:25.4560124Z *** The column [dbo].[Foo].[Bar] is being dropped, data loss could occur.
2016-10-26T18:12:26.2098293Z Initializing deployment (Complete)
2016-10-26T18:12:26.2098293Z Analyzing deployment plan (Start)
2016-10-26T18:12:26.2098293Z Analyzing deployment plan (Complete)
2016-10-26T18:12:26.2098293Z Updating database (Start)
2016-10-26T18:12:29.5605253Z An error occurred while the batch was being executed.
2016-10-26T18:12:29.5675257Z Updating database (Failed)
2016-10-26T18:12:30.4919483Z 
2016-10-26T18:12:30.6439495Z ##[error]

SerializedRemoteException      : 
SerializedRemoteInvocationInfo : 
ErrorRecord                    : *** Could not deploy package.
StackTrace                     :    at System.Management.Automation.Interpreter.ThrowInstruction.Run(InterpretedFrame 
                                 frame)
                                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(Int
                                 erpretedFrame frame)
WasThrownFromThrowStatement    : True
Message                        : *** Could not deploy package.
Data                           : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException                 : 
TargetSite                     : Void CheckActionPreference(System.Management.Automation.Language.FunctionContext, 
                                 System.Exception)
HelpLink                       : 
Source                         : System.Management.Automation
HResult                        : -2146233087

2016-10-26T18:12:30.6629481Z ##[section]Finishing: Execute Azure SQL : DacpacTask

我在该版本中包含了一些其他数据库更改,但是当我还原删除列的提交时,发布成功了。

即使NULL列中只有Bar,我也验证了同样的问题。

(显然我可以使用SSMS手动删除列,但是拥有CI / CD系统的目的是自动化所有内容,所以我不必这样做。)

如何使用VSTS DacpacTask删除列?

1 个答案:

答案 0 :(得分:3)

您需要在Execute Azure SQL:DacpacTask构建步骤的其他SqlPackage.exe参数中将BlockOnPossibleDataLoss参数指定为false。 enter image description here