SSDT- SQL DB DEPLOY DACPAC - 在现有生产服务器上失败



我正在使用Azure/Release to SQL Deploy。我有一个要部署的 DACPAC 文件,但我 (1( 更改了列数据类型,(2( 删除了已经包含数据的表上的一些列,(3( 并添加了一些 FK 列。但由于已经有这方面的生产数据,部署会失败。在这些情况下应该采取什么解决方案? SQL 部署映像

The column [dbo].[TableSample][ColumnSample] is being dropped, data loss could occur. 
The type for column Description in table [dbo].[Table2] is currently NVARCHAR (1024) NULL but is being changed to NVARCHAR (100) NOT NULL. Data loss could occur. 
The type for column Id in table [dbo].[Table3] is currently UNIQUEIDENTIFIER NOT NULL but is being changed to INT NOT NULL. 
There is no implicit or explicit conversion. *** 
The column [sampleColumnId] on table [dbo].[Table4] must be added
, but the column has no default value and does not allow NULL values. If the table contains data, the ALTER script will not work. 
To avoid this issue you must either: add a default value to the column, mark it as allowing NULL values, or enable the generation of smart-defaults as a deployment option. 

可以使用发布选项中的"允许数据丢失"选项来关闭"数据丢失"警告。 它只是警告您正在删除列或转到较小的数据长度。

您的"Table3"更改无法保留数据。GUID 不适合 INT 列。您可能需要考虑删除/重新创建表或将当前 ID 列重命名为其他列(可能是 OldId(,并添加 INT 类型的新 ID,可能带有 Identity(1,1(。

但是最后一列 - 您正在尝试向现有表添加一个没有默认值的 NOT NULL 列。允许 NULL 或在列上放置命名的默认值,以便可以添加该列。

最新更新