
--Migration_RCCP_20221013_110116.txt
CREATE TABLE [dbo].[Rules] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [RuleType] [int] NOT NULL,
    [Params] [nvarchar](max),
    [IsActive] [bit] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.Rules] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[RuleEngineActions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Gateway] [int] NOT NULL,
    [Payload] [nvarchar](max),
    [RuleId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.RuleEngineActions] PRIMARY KEY ([ID])
)
ALTER TABLE [dbo].[RuleActions] ADD [RuleId] [bigint] NOT NULL DEFAULT 0
CREATE INDEX [IX_RuleId] ON [dbo].[RuleEngineActions]([RuleId])
ALTER TABLE [dbo].[RuleEngineActions] ADD CONSTRAINT [FK_dbo.RuleEngineActions_dbo.Rules_RuleId] FOREIGN KEY ([RuleId]) REFERENCES [dbo].[Rules] ([ID]) ON DELETE CASCADE
