Skip to content

Commit

Permalink
Use CREATE OR ALTER where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
differsthecat committed Aug 11, 2023
1 parent 345583e commit bdb2409
Showing 1 changed file with 20 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,93 +2,46 @@
* Add Manage permission to collections
*/

IF OBJECT_ID('[dbo].[CollectionUser_ReadByCollectionId]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[CollectionUser_ReadByCollectionId]
END
GO

IF OBJECT_ID('[dbo].[CollectionGroup_ReadByCollectionId]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[CollectionGroup_ReadByCollectionId]
END
GO

-- Drop procedures that use the SelectionReadOnlyArray type
IF OBJECT_ID('[dbo].[Group_CreateWithCollections]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Group_CreateWithCollections]
END
GO

IF OBJECT_ID('[dbo].[Group_UpdateWithCollections]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Group_UpdateWithCollections]
END
GO

IF OBJECT_ID('[dbo].[OrganizationUser_CreateWithCollections]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[OrganizationUser_CreateWithCollections]
END
GO

IF OBJECT_ID('[dbo].[OrganizationUser_UpdateWithCollections]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[OrganizationUser_UpdateWithCollections]
END
GO

IF OBJECT_ID('[dbo].[Collection_CreateWithGroupsAndUsers]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Collection_CreateWithGroupsAndUsers]
END
GO

IF OBJECT_ID('[dbo].[Collection_UpdateWithGroupsAndUsers]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Collection_UpdateWithGroupsAndUsers]
END
GO

IF OBJECT_ID('[dbo].[CollectionUser_UpdateUsers]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[CollectionUser_UpdateUsers]
END
GO

IF OBJECT_ID('[dbo].[OrganizationUserUserDetails_ReadWithCollectionsById]') IS NOT NULL
IF OBJECT_ID('[dbo].[Group_UpdateWithCollections]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[OrganizationUserUserDetails_ReadWithCollectionsById]
DROP PROCEDURE [dbo].[Group_UpdateWithCollections]
END
GO

IF OBJECT_ID('[dbo].[UserCollectionDetails]') IS NOT NULL
IF OBJECT_ID('[dbo].[Collection_UpdateWithGroupsAndUsers]') IS NOT NULL
BEGIN
DROP FUNCTION [dbo].[UserCollectionDetails]
DROP PROCEDURE [dbo].[Collection_UpdateWithGroupsAndUsers]
END
GO

IF OBJECT_ID('[dbo].[Collection_ReadByIdUserId]') IS NOT NULL
IF OBJECT_ID('[dbo].[OrganizationUser_CreateWithCollections]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Collection_ReadByIdUserId]
DROP PROCEDURE [dbo].[OrganizationUser_CreateWithCollections]
END
GO

IF OBJECT_ID('[dbo].[Collection_ReadByUserId]') IS NOT NULL
IF OBJECT_ID('[dbo].[OrganizationUser_UpdateWithCollections]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Collection_ReadByUserId]
DROP PROCEDURE [dbo].[OrganizationUser_UpdateWithCollections]
END

GO
IF OBJECT_ID('[dbo].[Collection_ReadWithGroupsAndUsersByUserId]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Collection_ReadWithGroupsAndUsersByUserId]
END

GO
IF OBJECT_ID('[dbo].[Group_ReadWithCollectionsById]') IS NOT NULL
IF OBJECT_ID('[dbo].[Collection_CreateWithGroupsAndUsers]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Group_ReadWithCollectionsById]
DROP PROCEDURE [dbo].[Collection_CreateWithGroupsAndUsers]
END
GO

Expand All @@ -106,6 +59,7 @@ CREATE TYPE [dbo].[SelectionReadOnlyArray] AS TABLE (
GO



--Add Manage Column
IF COL_LENGTH('[dbo].[CollectionUser]', 'Manage') IS NULL
BEGIN
Expand All @@ -120,7 +74,7 @@ IF COL_LENGTH('[dbo].[CollectionGroup]', 'Manage') IS NULL
END
GO

CREATE PROCEDURE [dbo].[CollectionUser_ReadByCollectionId]
CREATE OR ALTER PROCEDURE [dbo].[CollectionUser_ReadByCollectionId]
@CollectionId UNIQUEIDENTIFIER
AS
BEGIN
Expand All @@ -138,7 +92,7 @@ BEGIN
END
GO

CREATE PROCEDURE [dbo].[CollectionGroup_ReadByCollectionId]
CREATE OR ALTER PROCEDURE [dbo].[CollectionGroup_ReadByCollectionId]
@CollectionId UNIQUEIDENTIFIER
AS
BEGIN
Expand Down Expand Up @@ -643,7 +597,7 @@ BEGIN
END
GO

CREATE PROCEDURE [dbo].[OrganizationUserUserDetails_ReadWithCollectionsById]
CREATE OR ALTER PROCEDURE [dbo].[OrganizationUserUserDetails_ReadWithCollectionsById]
@Id UNIQUEIDENTIFIER
AS
BEGIN
Expand All @@ -665,7 +619,7 @@ BEGIN
END
GO

CREATE FUNCTION [dbo].[UserCollectionDetails](@UserId UNIQUEIDENTIFIER)
CREATE OR ALTER FUNCTION [dbo].[UserCollectionDetails](@UserId UNIQUEIDENTIFIER)
RETURNS TABLE
AS RETURN
SELECT
Expand Down Expand Up @@ -720,7 +674,7 @@ WHERE
)
GO

CREATE PROCEDURE [dbo].[Collection_ReadByIdUserId]
CREATE OR ALTER PROCEDURE [dbo].[Collection_ReadByIdUserId]
@Id UNIQUEIDENTIFIER,
@UserId UNIQUEIDENTIFIER
AS
Expand Down Expand Up @@ -750,7 +704,7 @@ BEGIN
END
GO

CREATE PROCEDURE [dbo].[Collection_ReadByUserId]
CREATE OR ALTER PROCEDURE [dbo].[Collection_ReadByUserId]
@UserId UNIQUEIDENTIFIER
AS
BEGIN
Expand Down Expand Up @@ -778,7 +732,7 @@ BEGIN
END
GO

CREATE PROCEDURE [dbo].[Collection_ReadWithGroupsAndUsersByUserId]
CREATE OR ALTER PROCEDURE [dbo].[Collection_ReadWithGroupsAndUsersByUserId]
@UserId UNIQUEIDENTIFIER
AS
BEGIN
Expand Down Expand Up @@ -819,7 +773,7 @@ BEGIN
END
GO

CREATE PROCEDURE [dbo].[Group_ReadWithCollectionsById]
CREATE OR ALTER PROCEDURE [dbo].[Group_ReadWithCollectionsById]
@Id UNIQUEIDENTIFIER
AS
BEGIN
Expand Down

0 comments on commit bdb2409

Please sign in to comment.