diff --git a/src/Sql/dbo/Stored Procedures/OrganizationSponsorship_OrganizationUserDeleted.sql b/src/Sql/dbo/Stored Procedures/OrganizationSponsorship_OrganizationUserDeleted.sql index 3722dad8b..ae8780b9c 100644 --- a/src/Sql/dbo/Stored Procedures/OrganizationSponsorship_OrganizationUserDeleted.sql +++ b/src/Sql/dbo/Stored Procedures/OrganizationSponsorship_OrganizationUserDeleted.sql @@ -7,7 +7,7 @@ BEGIN UPDATE OS SET - [SponsoringOrganizationUserId] = NULL + [ToDelete] = 1 FROM [dbo].[OrganizationSponsorship] OS WHERE diff --git a/src/Sql/dbo/Stored Procedures/OrganizationSponsorship_OrganizationUsersDeleted.sql b/src/Sql/dbo/Stored Procedures/OrganizationSponsorship_OrganizationUsersDeleted.sql index 10c8ee77b..203d40559 100644 --- a/src/Sql/dbo/Stored Procedures/OrganizationSponsorship_OrganizationUsersDeleted.sql +++ b/src/Sql/dbo/Stored Procedures/OrganizationSponsorship_OrganizationUsersDeleted.sql @@ -7,7 +7,7 @@ BEGIN UPDATE OS SET - [SponsoringOrganizationUserId] = NULL + [ToDelete] = 1 FROM [dbo].[OrganizationSponsorship] OS INNER JOIN diff --git a/util/Migrator/DbScripts/2022-05-23_00_OrgUserDelete.sql b/util/Migrator/DbScripts/2022-05-23_00_OrgUserDelete.sql new file mode 100644 index 000000000..b341b9af9 --- /dev/null +++ b/util/Migrator/DbScripts/2022-05-23_00_OrgUserDelete.sql @@ -0,0 +1,47 @@ +-- OrganizationSponsorship_OrganizationUserDeleted +IF OBJECT_ID('[dbo].[OrganizationSponsorship_OrganizationUserDeleted]') IS NOT NULL +BEGIN + DROP PROCEDURE [dbo].[OrganizationSponsorship_OrganizationUserDeleted] +END +GO + +CREATE PROCEDURE [dbo].[OrganizationSponsorship_OrganizationUserDeleted] + @OrganizationUserId UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + + UPDATE + OS + SET + [ToDelete] = 1 + FROM + [dbo].[OrganizationSponsorship] OS + WHERE + [SponsoringOrganizationUserId] = @OrganizationUserId +END +GO + +-- OrganizationSponsorship_OrganizationUsersDeleted +IF OBJECT_ID('[dbo].[OrganizationSponsorship_OrganizationUsersDeleted]') IS NOT NULL +BEGIN + DROP PROCEDURE [dbo].[OrganizationSponsorship_OrganizationUsersDeleted] +END +GO + +CREATE PROCEDURE [dbo].[OrganizationSponsorship_OrganizationUsersDeleted] + @SponsoringOrganizationUserIds [dbo].[GuidIdArray] READONLY +AS +BEGIN + SET NOCOUNT ON + + UPDATE + OS + SET + [ToDelete] = 1 + FROM + [dbo].[OrganizationSponsorship] OS + INNER JOIN + @SponsoringOrganizationUserIds I ON I.Id = OS.SponsoringOrganizationUserId +END +GO