diff --git a/Oqtane.Server/Filters/UpgradeFilter.cs b/Oqtane.Server/Filters/UpgradeFilter.cs
index 6e76c3f0..57b6ed28 100644
--- a/Oqtane.Server/Filters/UpgradeFilter.cs
+++ b/Oqtane.Server/Filters/UpgradeFilter.cs
@@ -88,9 +88,9 @@ namespace Oqtane.Filters
Thread.Sleep(5000);
}
- // get initialization script and update connectionstring in Tenants seed data
+ // get master initialization script and update connectionstring in seed data
string initializationScript = "";
- using (StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + "\\Scripts\\Initialize.sql"))
+ using (StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + "\\Scripts\\Master.sql"))
{
initializationScript = reader.ReadToEnd();
}
@@ -98,7 +98,7 @@ namespace Oqtane.Filters
// handle upgrade scripts
var dbUpgradeConfig = DeployChanges.To.SqlDatabase(connectionString)
- .WithScript(new DbUp.Engine.SqlScript("Initialize.sql", initializationScript))
+ .WithScript(new DbUp.Engine.SqlScript("Master.sql", initializationScript))
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly()); // upgrade scripts should be added to /Scripts folder as Embedded Resources
var dbUpgrade = dbUpgradeConfig.Build();
if (dbUpgrade.IsUpgradeRequired())
diff --git a/Oqtane.Server/Oqtane.Server.csproj b/Oqtane.Server/Oqtane.Server.csproj
index 311e5b0f..c27a89be 100644
--- a/Oqtane.Server/Oqtane.Server.csproj
+++ b/Oqtane.Server/Oqtane.Server.csproj
@@ -26,7 +26,12 @@
-
+
+
+
+
+
+
diff --git a/Oqtane.Server/Scripts/Master.sql b/Oqtane.Server/Scripts/Master.sql
new file mode 100644
index 00000000..1d76ad91
--- /dev/null
+++ b/Oqtane.Server/Scripts/Master.sql
@@ -0,0 +1,64 @@
+/*
+
+Create tables
+
+*/
+CREATE TABLE [dbo].[Alias](
+ [AliasId] [int] IDENTITY(1,1) NOT NULL,
+ [Name] [nvarchar](200) NOT NULL,
+ [TenantId] [int] NOT NULL,
+ [SiteId] [int] NOT NULL,
+ CONSTRAINT [PK_Alias] PRIMARY KEY CLUSTERED
+ (
+ [AliasId] ASC
+ )
+)
+GO
+
+CREATE TABLE [dbo].[Tenant](
+ [TenantId] [int] IDENTITY(1,1) NOT NULL,
+ [Name] [nvarchar](100) NOT NULL,
+ [DBConnectionString] [nvarchar](1024) NOT NULL,
+ [DBSchema] [nvarchar](50) NOT NULL
+ CONSTRAINT [PK_Tenant] PRIMARY KEY CLUSTERED
+ (
+ [TenantId] ASC
+ )
+)
+GO
+
+
+/*
+
+Create foreign key relationships
+
+*/
+ALTER TABLE [dbo].[Alias] WITH CHECK ADD CONSTRAINT [FK_Alias_Tenant] FOREIGN KEY([TenantId])
+REFERENCES [dbo].[Tenant] ([TenantId])
+ON DELETE CASCADE
+GO
+
+/*
+
+Create seed data
+
+*/
+SET IDENTITY_INSERT [dbo].[Tenant] ON
+GO
+INSERT [dbo].[Tenant] ([TenantId], [Name], [DBConnectionString], [DBSchema])
+VALUES (1, N'Tenant1', N'{ConnectionString}', N'')
+GO
+SET IDENTITY_INSERT [dbo].[Tenant] OFF
+GO
+
+SET IDENTITY_INSERT [dbo].[Alias] ON
+GO
+INSERT [dbo].[Alias] ([AliasId], [Name], [TenantId], [SiteId])
+VALUES (1, N'localhost:44357', 1, 1)
+GO
+INSERT [dbo].[Alias] ([AliasId], [Name], [TenantId], [SiteId])
+VALUES (2, N'localhost:44357/site2', 1, 2)
+GO
+SET IDENTITY_INSERT [dbo].[Alias] OFF
+GO
+
diff --git a/Oqtane.Server/Scripts/Initialize.sql b/Oqtane.Server/Scripts/Tenant.sql
similarity index 94%
rename from Oqtane.Server/Scripts/Initialize.sql
rename to Oqtane.Server/Scripts/Tenant.sql
index 62349ac0..b43bf28a 100644
--- a/Oqtane.Server/Scripts/Initialize.sql
+++ b/Oqtane.Server/Scripts/Tenant.sql
@@ -3,29 +3,6 @@
Create tables
*/
-CREATE TABLE [dbo].[Alias](
- [AliasId] [int] IDENTITY(1,1) NOT NULL,
- [Name] [nvarchar](200) NOT NULL,
- [TenantId] [int] NOT NULL,
- [SiteId] [int] NOT NULL,
- CONSTRAINT [PK_Alias] PRIMARY KEY CLUSTERED
- (
- [AliasId] ASC
- )
-)
-GO
-
-CREATE TABLE [dbo].[Tenant](
- [TenantId] [int] IDENTITY(1,1) NOT NULL,
- [Name] [nvarchar](100) NOT NULL,
- [DBConnectionString] [nvarchar](1024) NOT NULL,
- [DBSchema] [nvarchar](50) NOT NULL
- CONSTRAINT [PK_Tenant] PRIMARY KEY CLUSTERED
- (
- [TenantId] ASC
- )
-)
-GO
CREATE TABLE [dbo].[Site](
[SiteId] [int] IDENTITY(1,1) NOT NULL,
@@ -140,34 +117,11 @@ REFERENCES [dbo].[Page] ([PageId])
ON DELETE CASCADE
GO
-ALTER TABLE [dbo].[Alias] WITH CHECK ADD CONSTRAINT [FK_Alias_Tenant] FOREIGN KEY([TenantId])
-REFERENCES [dbo].[Tenant] ([TenantId])
-ON DELETE CASCADE
-GO
-
/*
Create seed data
*/
-SET IDENTITY_INSERT [dbo].[Tenant] ON
-GO
-INSERT [dbo].[Tenant] ([TenantId], [Name], [DBConnectionString], [DBSchema])
-VALUES (1, N'Tenant1', N'{ConnectionString}', N'')
-GO
-SET IDENTITY_INSERT [dbo].[Tenant] OFF
-GO
-
-SET IDENTITY_INSERT [dbo].[Alias] ON
-GO
-INSERT [dbo].[Alias] ([AliasId], [Name], [TenantId], [SiteId])
-VALUES (1, N'localhost:44357', 1, 1)
-GO
-INSERT [dbo].[Alias] ([AliasId], [Name], [TenantId], [SiteId])
-VALUES (2, N'localhost:44357/site2', 1, 2)
-GO
-SET IDENTITY_INSERT [dbo].[Alias] OFF
-GO
SET IDENTITY_INSERT [dbo].[Site] ON
GO