Split master and tenant installation scripts
This commit is contained in:
64
Oqtane.Server/Scripts/Master.sql
Normal file
64
Oqtane.Server/Scripts/Master.sql
Normal file
@ -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
|
||||
|
@ -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
|
Reference in New Issue
Block a user