DacFx
DacFx copied to clipboard
Not Null Persisted Computed Column Permanent Schema Diff
- SqlPackage or DacFx Version:
162.4.92.3 - .NET Framework (Windows-only) or .NET Core:
both - Environment (local platform and source/target platforms):
Microsoft SQL Server 2019 (RTM-CU27-GDR) (KB5040948) - 15.0.4382.1 (X64) Jul 1 2024 20:03:23 Copyright (C) 2019 Microsoft Corporation Express Edition (64-bit) on Windows 10 Enterprise 10.0 <X64> (Build 22631: ) (Hypervisor)
Steps to Reproduce:
- Create a table definition in a sqlproj
CREATE TABLE [dbo].[MyTable](
NormalColumn INT NOT NULL,
ComputedColumn AS NormalColumn PERSISTED,
) ON [PRIMARY]
- Build and deploy this as a dacpac
- The computed column is dropped and recreated when it shouldn't be
ALTER TABLE [dbo].[MyTable] DROP COLUMN [ComputedColumn];
ALTER TABLE [dbo].[MyTable] ADD [ComputedColumn] AS NormalColumn PERSISTED;
Similar examples: This does not result in a column drop and create
CREATE TABLE [dbo].[MyTable](
NormalColumn INT NULL,
ComputedColumn AS NormalColumn PERSISTED,
) ON [PRIMARY]
Neither does this:
CREATE TABLE [dbo].[MyTable](
NormalColumn INT NOT NULL,
ComputedColumn AS NormalColumn,
) ON [PRIMARY]
And neither does this
CREATE TABLE [dbo].[MyTable](
NormalColumn INT NOT NULL,
ComputedColumn AS NormalColumn PERSISTED NOT NULL,
) ON [PRIMARY]
It seems to be a combination of the NOT NULL and PERSISTED
Did this occur in prior versions? If not - which version(s) did it work in?
(DacFx/SqlPackage/SSMS/Azure Data Studio)
@dzsquared since you have "persistent-schema-differences" tag maybe it should be applied to this issue too.