From 8e7cb082ad66e8b30ee6c5e9090b6409cffa916a Mon Sep 17 00:00:00 2001 From: Matt Portune Date: Sun, 21 Jun 2020 23:35:05 -0400 Subject: [PATCH 1/5] DB support for SSO config --- src/Sql/Sql.sqlproj | 4 ++++ .../SsoConfig_ReadByIdentifier.sql | 13 +++++++++++++ .../SsoConfig_ReadByOrganizationId.sql | 13 +++++++++++++ src/Sql/dbo/Tables/SsoConfig.sql | 8 ++++++++ src/Sql/dbo/Views/SsoConfigView.sql | 6 ++++++ util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql | 12 ++++++++++++ 6 files changed, 56 insertions(+) create mode 100644 src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql create mode 100644 src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql create mode 100644 src/Sql/dbo/Tables/SsoConfig.sql create mode 100644 src/Sql/dbo/Views/SsoConfigView.sql create mode 100644 util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql diff --git a/src/Sql/Sql.sqlproj b/src/Sql/Sql.sqlproj index 05084eadc..6db42f89f 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 000000000..6e5aac0ea --- /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 + * + FROM + [dbo].[SsoConfigView] + WHERE + [Identifier] = @Identifier +END \ No newline at end of file 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 000000000..6bbf5a6d8 --- /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 + * + FROM + [dbo].[SsoConfigView] + WHERE + [OrganizationId] = @OrganizationId +END \ No newline at end of file diff --git a/src/Sql/dbo/Tables/SsoConfig.sql b/src/Sql/dbo/Tables/SsoConfig.sql new file mode 100644 index 000000000..2c0ecfeb7 --- /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 000000000..28f889c48 --- /dev/null +++ b/src/Sql/dbo/Views/SsoConfigView.sql @@ -0,0 +1,6 @@ +CREATE VIEW [dbo].[SsoConfigView] +AS +SELECT + * +FROM + [dbo].[SsoConfig] \ No newline at end of file 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 000000000..dadf2eb49 --- /dev/null +++ b/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql @@ -0,0 +1,12 @@ +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 \ No newline at end of file From 519226f8240dd7a93ea3d9345fdcffd3e6949e0f Mon Sep 17 00:00:00 2001 From: Matt Portune Date: Sun, 21 Jun 2020 23:42:27 -0400 Subject: [PATCH 2/5] formatting --- src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql | 2 +- .../dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql | 2 +- src/Sql/dbo/Views/SsoConfigView.sql | 2 +- util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql index 6e5aac0ea..836f0cf85 100644 --- a/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql +++ b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql @@ -10,4 +10,4 @@ BEGIN [dbo].[SsoConfigView] WHERE [Identifier] = @Identifier -END \ No newline at end of file +END diff --git a/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql index 6bbf5a6d8..f748b159e 100644 --- a/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql +++ b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql @@ -10,4 +10,4 @@ BEGIN [dbo].[SsoConfigView] WHERE [OrganizationId] = @OrganizationId -END \ No newline at end of file +END diff --git a/src/Sql/dbo/Views/SsoConfigView.sql b/src/Sql/dbo/Views/SsoConfigView.sql index 28f889c48..7bcfe15b4 100644 --- a/src/Sql/dbo/Views/SsoConfigView.sql +++ b/src/Sql/dbo/Views/SsoConfigView.sql @@ -3,4 +3,4 @@ AS SELECT * FROM - [dbo].[SsoConfig] \ No newline at end of file + [dbo].[SsoConfig] diff --git a/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql b/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql index dadf2eb49..20b8f2203 100644 --- a/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql +++ b/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql @@ -9,4 +9,4 @@ BEGIN CONSTRAINT [FK_SsoConfig_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ); END -GO \ No newline at end of file +GO From 6f53ef484760055918fad0e92a5878f09ca97462 Mon Sep 17 00:00:00 2001 From: Matt Portune Date: Mon, 22 Jun 2020 09:36:40 -0400 Subject: [PATCH 3/5] formatting --- src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql | 4 ++-- .../dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql index 836f0cf85..bcbd01f7e 100644 --- a/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql +++ b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByIdentifier.sql @@ -1,10 +1,10 @@ CREATE PROCEDURE [dbo].[SsoConfig_ReadByIdentifier] -@Identifier NVARCHAR(50) + @Identifier NVARCHAR(50) AS BEGIN SET NOCOUNT ON - SELECT + SELECT TOP 1 * FROM [dbo].[SsoConfigView] diff --git a/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql index f748b159e..eed6fc1ae 100644 --- a/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql +++ b/src/Sql/dbo/Stored Procedures/SsoConfig_ReadByOrganizationId.sql @@ -1,10 +1,10 @@ CREATE PROCEDURE [dbo].[SsoConfig_ReadByOrganizationId] -@OrganizationId UNIQUEIDENTIFIER + @OrganizationId UNIQUEIDENTIFIER AS BEGIN SET NOCOUNT ON - SELECT + SELECT TOP 1 * FROM [dbo].[SsoConfigView] From d0a98d6cf34482c8d45ce3421e22c3d3c55316f3 Mon Sep 17 00:00:00 2001 From: Matt Portune Date: Mon, 22 Jun 2020 09:49:16 -0400 Subject: [PATCH 4/5] Added missing migration functionality --- .../DbScripts/2020-06-16_00_OrgSso.sql | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql b/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql index 20b8f2203..3fecc9c88 100644 --- a/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql +++ b/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql @@ -10,3 +10,59 @@ BEGIN ); 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 From aa19be2c0c904e63b673bb91b69116f02107ef42 Mon Sep 17 00:00:00 2001 From: Matt Portune Date: Mon, 22 Jun 2020 10:45:37 -0400 Subject: [PATCH 5/5] formatting --- .../DbScripts/2020-06-16_00_OrgSso.sql | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql b/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql index 3fecc9c88..a3ba8442d 100644 --- a/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql +++ b/util/Migrator/DbScripts/2020-06-16_00_OrgSso.sql @@ -12,9 +12,9 @@ END GO IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'SsoConfig') - BEGIN - DROP VIEW [dbo].[SsoConfigView] - END +BEGIN + DROP VIEW [dbo].[SsoConfigView] +END GO CREATE VIEW [dbo].[SsoConfigView] @@ -26,9 +26,9 @@ FROM GO IF OBJECT_ID('[dbo].[SsoConfig_ReadByIdentifier]') IS NOT NULL - BEGIN - DROP PROCEDURE [dbo].[SsoConfig_ReadByIdentifier] - END +BEGIN + DROP PROCEDURE [dbo].[SsoConfig_ReadByIdentifier] +END GO CREATE PROCEDURE [dbo].[SsoConfig_ReadByIdentifier] @@ -47,9 +47,9 @@ END GO IF OBJECT_ID('[dbo].[SsoConfig_ReadByOrganizationId]') IS NOT NULL - BEGIN - DROP PROCEDURE [dbo].[SsoConfig_ReadByOrganizationId] - END +BEGIN + DROP PROCEDURE [dbo].[SsoConfig_ReadByOrganizationId] +END GO CREATE PROCEDURE [dbo].[SsoConfig_ReadByOrganizationId]