diff --git a/src/Sql/Sql.sqlproj b/src/Sql/Sql.sqlproj index 05084eadc0..6db42f89f0 100644 --- a/src/Sql/Sql.sqlproj +++ b/src/Sql/Sql.sqlproj @@ -69,7 +69,10 @@ + + + @@ -84,6 +87,7 @@ + diff --git a/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql new file mode 100644 index 0000000000..bcbd01f7ea --- /dev/null +++ b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql @@ -0,0 +1,13 @@ +CREATE PROCEDURE [dbo].[SsoConfig_ReadByIdentifier] + @Identifier NVARCHAR(50) +AS +BEGIN + SET NOCOUNT ON + + SELECT TOP 1 + * + FROM + [dbo].[SsoConfigView] + WHERE + [Identifier] = @Identifier +END diff --git a/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql new file mode 100644 index 0000000000..eed6fc1ae1 --- /dev/null +++ b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql @@ -0,0 +1,13 @@ +CREATE PROCEDURE [dbo].[SsoConfig_ReadByOrganizationId] + @OrganizationId UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + + SELECT TOP 1 + * + FROM + [dbo].[SsoConfigView] + WHERE + [OrganizationId] = @OrganizationId +END diff --git a/src/Sql/dbo/Tables/SsoConfig.sql b/src/Sql/dbo/Tables/SsoConfig.sql new file mode 100644 index 0000000000..2c0ecfeb7d --- /dev/null +++ b/src/Sql/dbo/Tables/SsoConfig.sql @@ -0,0 +1,8 @@ +CREATE TABLE [dbo].[SsoConfig] ( + [OrganizationId] UNIQUEIDENTIFIER NULL, + [Identifier] NVARCHAR (50) NULL, + [Data] NVARCHAR (MAX) NULL, + [CreationDate] DATETIME2 (7) NOT NULL, + [RevisionDate] DATETIME2 (7) NOT NULL, + CONSTRAINT [FK_SsoConfig_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) +); diff --git a/src/Sql/dbo/Views/SsoConfigView.sql b/src/Sql/dbo/Views/SsoConfigView.sql new file mode 100644 index 0000000000..7bcfe15b4b --- /dev/null +++ b/src/Sql/dbo/Views/SsoConfigView.sql @@ -0,0 +1,6 @@ +CREATE VIEW [dbo].[SsoConfigView] +AS +SELECT + * +FROM + [dbo].[SsoConfig] diff --git a/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql b/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql new file mode 100644 index 0000000000..a3ba8442da --- /dev/null +++ b/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql @@ -0,0 +1,68 @@ +IF OBJECT_ID('[dbo].[SsoConfig]') IS NULL +BEGIN + CREATE TABLE [dbo].[SsoConfig] ( + [OrganizationId] UNIQUEIDENTIFIER NULL, + [Identifier] NVARCHAR (50) NULL, + [Data] NVARCHAR (MAX) NULL, + [CreationDate] DATETIME2 (7) NOT NULL, + [RevisionDate] DATETIME2 (7) NOT NULL, + CONSTRAINT [FK_SsoConfig_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) + ); +END +GO + +IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'SsoConfig') +BEGIN + DROP VIEW [dbo].[SsoConfigView] +END +GO + +CREATE VIEW [dbo].[SsoConfigView] +AS +SELECT + * +FROM + [dbo].[SsoConfig] +GO + +IF OBJECT_ID('[dbo].[SsoConfig_ReadByIdentifier]') IS NOT NULL +BEGIN + DROP PROCEDURE [dbo].[SsoConfig_ReadByIdentifier] +END +GO + +CREATE PROCEDURE [dbo].[SsoConfig_ReadByIdentifier] + @Identifier NVARCHAR(50) +AS +BEGIN + SET NOCOUNT ON + + SELECT TOP 1 + * + FROM + [dbo].[SsoConfigView] + WHERE + [Identifier] = @Identifier +END +GO + +IF OBJECT_ID('[dbo].[SsoConfig_ReadByOrganizationId]') IS NOT NULL +BEGIN + DROP PROCEDURE [dbo].[SsoConfig_ReadByOrganizationId] +END +GO + +CREATE PROCEDURE [dbo].[SsoConfig_ReadByOrganizationId] + @OrganizationId UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + + SELECT TOP 1 + * + FROM + [dbo].[SsoConfigView] + WHERE + [OrganizationId] = @OrganizationId +END +GO