JustPaste.it

diff --git a/RedGateDatabaseInfo.xml b/RedGateDatabaseInfo.xml
index 883ac00..fdc0858 100644
--- a/RedGateDatabaseInfo.xml
+++ b/RedGateDatabaseInfo.xml
@@ -5,7 +5,7 @@
<DefaultSchema>dbo</DefaultSchema>
<DefaultUser>dbo</DefaultUser>
<DefaultFilegroup>PRIMARY</DefaultFilegroup>
- <DatabaseVersion>13</DatabaseVersion>
+ <DatabaseVersion>12</DatabaseVersion>
<IsAzure>False</IsAzure>
<MaxDataFileSize>10485760</MaxDataFileSize>
<WriteToFileOptions>
diff --git a/Tables/Reference.MasterNotificationTemplate.sql b/Tables/Reference.MasterNotificationTemplate.sql
new file mode 100644
index 0000000..e74ad6f
--- /dev/null
+++ b/Tables/Reference.MasterNotificationTemplate.sql
@@ -0,0 +1,14 @@
+CREATE TABLE [Reference].[MasterNotificationTemplate]
+(
+[Id] [int] NOT NULL IDENTITY(1, 1),
+[Title] [nvarchar] (100) COLLATE Latin1_General_CI_AS NOT NULL,
+[Subject] [nvarchar] (250) COLLATE Latin1_General_CI_AS NULL,
+[Description] [nvarchar] (500) COLLATE Latin1_General_CI_AS NULL,
+[NotificationTemplateHtml] [nvarchar] (max) COLLATE Latin1_General_CI_AS NOT NULL,
+[PublishDate] [date] NULL,
+[Deleted] [bit] NOT NULL CONSTRAINT [DF_MasterNotificationTemplate_Deleted] DEFAULT ((0)),
+[RecordVersion] [timestamp] NOT NULL
+) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
+GO
+ALTER TABLE [Reference].[MasterNotificationTemplate] ADD CONSTRAINT [PK_MasterNotificationTemplate_Id] PRIMARY KEY CLUSTERED ([Id]) ON [PRIMARY]
+GO
diff --git a/Tables/Reference.NotificationChannel.sql b/Tables/Reference.NotificationChannel.sql
new file mode 100644
index 0000000..3bc55fd
--- /dev/null
+++ b/Tables/Reference.NotificationChannel.sql
@@ -0,0 +1,11 @@
+CREATE TABLE [Reference].[NotificationChannel]
+(
+[Id] [int] NOT NULL IDENTITY(1, 1),
+[ChannelName] [nvarchar] (50) COLLATE Latin1_General_CI_AS NOT NULL,
+[Description] [varchar] (200) COLLATE Latin1_General_CI_AS NULL,
+[Deleted] [bit] NOT NULL CONSTRAINT [DF_NotificationChannel_Deleted] DEFAULT ((0)),
+[RecordVersion] [timestamp] NOT NULL
+) ON [PRIMARY]
+GO
+ALTER TABLE [Reference].[NotificationChannel] ADD CONSTRAINT [PK_NotificationChannel_Id] PRIMARY KEY CLUSTERED ([Id]) ON [PRIMARY]
+GO
diff --git a/Tables/Reference.NotificationLevel.sql b/Tables/Reference.NotificationLevel.sql
new file mode 100644
index 0000000..1f5ccd0
--- /dev/null
+++ b/Tables/Reference.NotificationLevel.sql
@@ -0,0 +1,10 @@
+CREATE TABLE [Reference].[NotificationLevel]
+(
+[Id] [int] NOT NULL IDENTITY(1, 1),
+[LevelName] [nvarchar] (50) COLLATE Latin1_General_CI_AS NOT NULL,
+[LevelDesc] [nvarchar] (150) COLLATE Latin1_General_CI_AS NULL,
+[Deleted] [bit] NOT NULL CONSTRAINT [DF_NotificationLevel_Deleted] DEFAULT ((0))
+) ON [PRIMARY]
+GO
+ALTER TABLE [Reference].[NotificationLevel] ADD CONSTRAINT [PK_NotificationLevel] PRIMARY KEY CLUSTERED ([Id]) ON [PRIMARY]
+GO
diff --git a/Tables/Reference.NotificationTemplate.sql b/Tables/Reference.NotificationTemplate.sql
index ad9dbfd..59045d8 100644
--- a/Tables/Reference.NotificationTemplate.sql
+++ b/Tables/Reference.NotificationTemplate.sql
@@ -1,20 +1,26 @@
CREATE TABLE [Reference].[NotificationTemplate]
(
[Id] [int] NOT NULL IDENTITY(1, 1),
-[MasterTemplateId] [int] NOT NULL,
+[MasterTemplateId] [int] NULL,
[Title] [nvarchar] (100) COLLATE Latin1_General_CI_AS NOT NULL,
[Subject] [nvarchar] (250) COLLATE Latin1_General_CI_AS NULL,
-[Description] [nvarchar] (500) COLLATE Latin1_General_CI_AS NULL,
-[TemplateHtml] [nvarchar] (max) COLLATE Latin1_General_CI_AS NOT NULL,
-[ChannelTypeId] [int] NOT NULL,
-[PublishDate] [date] NULL,
+[DatePresent] [date] NULL,
+[DateExpired] [date] NULL,
+[NotificationChannelId] [int] NULL,
+[NotificationHtml] [nvarchar] (max) COLLATE Latin1_General_CI_AS NULL,
+[NotificationLevelId] [int] NOT NULL,
[Deleted] [bit] NOT NULL CONSTRAINT [DF_NotificationTemplate_Deleted] DEFAULT ((0)),
-[RecordVersion] [timestamp] NOT NULL
+[RecordVersion] [timestamp] NOT NULL,
+[CreatedByUserId] [nvarchar] (128) COLLATE Latin1_General_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
-ALTER TABLE [Reference].[NotificationTemplate] ADD CONSTRAINT [PK_NotificationTemplate_Id] PRIMARY KEY CLUSTERED ([Id]) ON [PRIMARY]
+ALTER TABLE [Reference].[NotificationTemplate] ADD CONSTRAINT [PK_NotificationtTemplate_Id] PRIMARY KEY CLUSTERED ([Id]) ON [PRIMARY]
GO
-ALTER TABLE [Reference].[NotificationTemplate] ADD CONSTRAINT [FK_NotificationTemplate_ChannelTypes] FOREIGN KEY ([ChannelTypeId]) REFERENCES [Reference].[ChannelType] ([Id])
+ALTER TABLE [Reference].[NotificationTemplate] ADD CONSTRAINT [FK_Notification_NotificationTemplate] FOREIGN KEY ([MasterTemplateId]) REFERENCES [Reference].[MasterNotificationTemplate] ([Id])
GO
-ALTER TABLE [Reference].[NotificationTemplate] ADD CONSTRAINT [FK_NotificationTemplate_NotificationMasterTemplate] FOREIGN KEY ([MasterTemplateId]) REFERENCES [Reference].[NotificationMasterTemplate] ([Id])
+ALTER TABLE [Reference].[NotificationTemplate] ADD CONSTRAINT [FK_NotificationTemplate_AspNetUsers] FOREIGN KEY ([CreatedByUserId]) REFERENCES [Security].[AspNetUsers] ([Id])
+GO
+ALTER TABLE [Reference].[NotificationTemplate] ADD CONSTRAINT [FK_NotificationTemplate_NotificationChannel] FOREIGN KEY ([NotificationChannelId]) REFERENCES [Reference].[NotificationChannel] ([Id])
+GO
+ALTER TABLE [Reference].[NotificationTemplate] ADD CONSTRAINT [FK_NotificationTemplate_NotificationLevel] FOREIGN KEY ([NotificationLevelId]) REFERENCES [Reference].[NotificationLevel] ([Id])
GO