
--Migration_RCCP_20220803_115451.txt
ALTER TABLE [dbo].[RuleActions] DROP CONSTRAINT [PK_dbo.RuleActions]
CREATE TABLE [dbo].[Rules] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [RuleType] [int] NOT NULL,
    [Params] [nvarchar](max),
    [IsActive] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.Rules] PRIMARY KEY ([ID])
)
ALTER TABLE [dbo].[RuleActions] ADD [RuleId] [bigint] NOT NULL DEFAULT 0
DECLARE @var0 nvarchar(128)
SELECT @var0 = name
FROM sys.default_constraints
WHERE parent_object_id = object_id(N'dbo.RuleActions')
AND col_name(parent_object_id, parent_column_id) = 'ID';
IF @var0 IS NOT NULL
    EXECUTE('ALTER TABLE [dbo].[RuleActions] DROP CONSTRAINT [' + @var0 + ']')
ALTER TABLE [dbo].[RuleActions] ALTER COLUMN [ID] [bigint] NOT NULL
ALTER TABLE [dbo].[RuleActions] ADD CONSTRAINT [PK_dbo.RuleActions] PRIMARY KEY ([ID])
CREATE INDEX [IX_ID] ON [dbo].[RuleActions]([ID])
ALTER TABLE [dbo].[RuleActions] ADD CONSTRAINT [FK_dbo.RuleActions_dbo.Rules_ID] FOREIGN KEY ([ID]) REFERENCES [dbo].[Rules] ([ID])

--Migration_RCCP_20220803_124316.txt
ALTER TABLE [dbo].[RuleActions] DROP CONSTRAINT [PK_dbo.RuleActions]
CREATE TABLE [dbo].[Rules] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [RuleType] [int] NOT NULL,
    [Params] [nvarchar](max),
    [IsActive] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.Rules] PRIMARY KEY ([ID])
)
ALTER TABLE [dbo].[RuleActions] ADD [RuleId] [bigint] NOT NULL DEFAULT 0
DECLARE @var0 nvarchar(128)
SELECT @var0 = name
FROM sys.default_constraints
WHERE parent_object_id = object_id(N'dbo.RuleActions')
AND col_name(parent_object_id, parent_column_id) = 'ID';
IF @var0 IS NOT NULL
    EXECUTE('ALTER TABLE [dbo].[RuleActions] DROP CONSTRAINT [' + @var0 + ']')
ALTER TABLE [dbo].[RuleActions] ALTER COLUMN [ID] [bigint] NOT NULL
ALTER TABLE [dbo].[RuleActions] ADD CONSTRAINT [PK_dbo.RuleActions] PRIMARY KEY ([ID])
CREATE INDEX [IX_ID] ON [dbo].[RuleActions]([ID])
ALTER TABLE [dbo].[RuleActions] ADD CONSTRAINT [FK_dbo.RuleActions_dbo.Rules_ID] FOREIGN KEY ([ID]) REFERENCES [dbo].[Rules] ([ID])

--Migration_RCCP_20220803_141930.txt
CREATE TABLE [dbo].[Rules] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [RuleType] [int] NOT NULL,
    [Params] [nvarchar](max),
    [IsActive] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.Rules] PRIMARY KEY ([ID])
)
ALTER TABLE [dbo].[RuleActions] ADD [RuleId] [bigint] NOT NULL DEFAULT 0
