我正在使用 Azure/Release 到 SQL 部署。我有一个 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 或在列上放置一个命名的默认值,以便可以添加该列。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句