Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment fails when system versioning table needs update and there's a new schema #309

Closed
llali opened this issue Jul 31, 2023 · 0 comments
Assignees
Labels
bug Something isn't working fixed-pending-release Fix in upcoming release
Milestone

Comments

@llali
Copy link
Member

llali commented Jul 31, 2023

  • SqlPackage or DacFx Version:
  • .NET Framework (Windows-only) or .NET Core:
  • Environment (local platform and source/target platforms):

Steps to Reproduce:

  1. Use the following scripts in SQL Project and deploy
CREATE SCHEMA [sc1]
GO

CREATE TABLE [sc1].[Table1] (
    [Id]                                         INT                                         IDENTITY (1, 1) NOT NULL,
    [CreatedDate]                                DATETIME                                    CONSTRAINT [DF_Table1_CreatedDate] DEFAULT GETUTCDATE() NOT NULL,
    [LastUpdatedDate]                            DATETIME                                    CONSTRAINT [DF_Table1_LastUpdatedDate] DEFAULT GETUTCDATE() NOT NULL,
    [SysStart]                                   DATETIME2 (7) GENERATED ALWAYS AS ROW START NOT NULL,
    [SysEnd]                                     DATETIME2 (7) GENERATED ALWAYS AS ROW END   NOT NULL,
    [EffectiveDate]                              DATE                                        NOT NULL,
    [SubFundCode]                                NVARCHAR (10)                               NULL,
    CONSTRAINT [PK_Table1_EffectiveDate_Id] PRIMARY KEY NONCLUSTERED ([EffectiveDate] ASC, [Id] ASC),
    INDEX [CCSIX_Table1] CLUSTERED COLUMNSTORE,
    PERIOD FOR SYSTEM_TIME ([SysStart], [SysEnd])
)
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE=[sc1].[Table1History], DATA_CONSISTENCY_CHECK=ON));
GO

  1. Then add a new table and schema, make a change in the existing system versioning table and deploy
REATE SCHEMA [sc2]
GO

CREATE SCHEMA [sc1]
GO

CREATE TABLE [sc2].[Table2] (
    [Id]                                                 INT                                         IDENTITY (1, 1) NOT NULL,
    [LastUpdatedDate]                                    DATETIME                                    CONSTRAINT [DF_Table2_LastUpdatedDate] DEFAULT GETUTCDATE() NOT NULL,
    [SysStart]                                           DATETIME2 (7) GENERATED ALWAYS AS ROW START NOT NULL,
    [SysEnd]                                             DATETIME2 (7) GENERATED ALWAYS AS ROW END   NOT NULL,
    [DataSetId]                                          UNIQUEIDENTIFIER                            NOT NULL,
    [ProcessId]                                          INT                                         NULL,
    [EffectiveDate]                                      DATE                                        NOT NULL,
    CONSTRAINT [PK_Table2_Id] PRIMARY KEY CLUSTERED ([Id] ASC),
    PERIOD FOR SYSTEM_TIME ([SysStart], [SysEnd])
)
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE=[sc2].[Table2History], DATA_CONSISTENCY_CHECK=ON, HISTORY_RETENTION_PERIOD=12 MONTH));
GO


CREATE TABLE [sc1].[Table1] (
    [Id]                                         INT                                         IDENTITY (1, 1) NOT NULL,
    [CreatedDate]                                DATETIME                                    CONSTRAINT [DF_Table1_CreatedDate] DEFAULT GETUTCDATE() NOT NULL,
    [LastUpdatedDate]                            DATETIME                                    CONSTRAINT [DF_Table1_LastUpdatedDate] DEFAULT GETUTCDATE() NOT NULL,
    [SysStart]                                   DATETIME2 (7) GENERATED ALWAYS AS ROW START NOT NULL,
    [SysEnd]                                     DATETIME2 (7) GENERATED ALWAYS AS ROW END   NOT NULL,
    [EffectiveDate]                              DATE                                        NOT NULL,
    [SubFundCode]                                NVARCHAR (10)                               NULL,
    CONSTRAINT [PK_Table1_EffectiveDate_Id] PRIMARY KEY NONCLUSTERED ([EffectiveDate] ASC, [Id] ASC),
    INDEX [CCSIX_Table1] CLUSTERED COLUMNSTORE,
    PERIOD FOR SYSTEM_TIME ([SysStart], [SysEnd])
)
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE=[sc1].[Table1History], DATA_CONSISTENCY_CHECK=ON, HISTORY_RETENTION_PERIOD=12 MONTH));
GO

Expected: deploys successfully
Actual: deploy fails because schema sc2 is created after the new table

Did this occur in prior versions? If not - which version(s) did it work in?

(DacFx/SqlPackage/SSMS/Azure Data Studio)

@llali llali added the bug Something isn't working label Jul 31, 2023
@llali llali self-assigned this Jul 31, 2023
@llali llali added bug Something isn't working fixed-pending-release Fix in upcoming release and removed bug Something isn't working labels Jul 31, 2023
@llali llali added this to the September 2023 (Next Release) milestone Jul 31, 2023
@llali llali closed this as completed Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed-pending-release Fix in upcoming release
Projects
None yet
Development

No branches or pull requests

1 participant