From 7577fa6f2f55e8ae00769d552e98b669780a8d3a Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Sat, 20 Dec 2025 16:02:23 +1000 Subject: [PATCH] fix sql style --- .../Collection_UpsertDefaultCollection.sql | 21 +++++++++---------- ..._01_Collection_UpsertDefaultCollection.sql | 20 +++++++++--------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/Sql/dbo/Stored Procedures/Collection_UpsertDefaultCollection.sql b/src/Sql/dbo/Stored Procedures/Collection_UpsertDefaultCollection.sql index 8e82aea184..f91a611842 100644 --- a/src/Sql/dbo/Stored Procedures/Collection_UpsertDefaultCollection.sql +++ b/src/Sql/dbo/Stored Procedures/Collection_UpsertDefaultCollection.sql @@ -13,10 +13,10 @@ AS BEGIN SET NOCOUNT ON - BEGIN TRANSACTION; + BEGIN TRANSACTION BEGIN TRY - SET @WasCreated = 1; + SET @WasCreated = 1 -- Insert Collection with DefaultCollectionOwner populated for constraint enforcement INSERT INTO [dbo].[Collection] @@ -42,7 +42,7 @@ BEGIN NULL, -- DefaultUserCollectionEmail 1, -- CollectionType.DefaultUserCollection @OrganizationUserId - ); + ) -- Insert CollectionUser INSERT INTO [dbo].[CollectionUser] @@ -60,29 +60,28 @@ BEGIN 0, -- ReadOnly = false 0, -- HidePasswords = false 1 -- Manage = true - ); + ) -- Bump user account revision dates - EXEC [dbo].[User_BumpAccountRevisionDateByCollectionId] @CollectionId, @OrganizationId; + EXEC [dbo].[User_BumpAccountRevisionDateByCollectionId] @CollectionId, @OrganizationId - COMMIT TRANSACTION; + COMMIT TRANSACTION END TRY BEGIN CATCH -- Check if error is unique constraint violation (error 2601 or 2627) IF ERROR_NUMBER() IN (2601, 2627) BEGIN -- Collection already exists, return gracefully - SET @WasCreated = 0; + SET @WasCreated = 0 IF @@TRANCOUNT > 0 - ROLLBACK TRANSACTION; + ROLLBACK TRANSACTION END ELSE BEGIN -- Unexpected error, rollback and re-throw IF @@TRANCOUNT > 0 - ROLLBACK TRANSACTION; - THROW; + ROLLBACK TRANSACTION + THROW END END CATCH END -GO diff --git a/util/Migrator/DbScripts/2025-12-20_01_Collection_UpsertDefaultCollection.sql b/util/Migrator/DbScripts/2025-12-20_01_Collection_UpsertDefaultCollection.sql index a5343dfa2e..044c53d405 100644 --- a/util/Migrator/DbScripts/2025-12-20_01_Collection_UpsertDefaultCollection.sql +++ b/util/Migrator/DbScripts/2025-12-20_01_Collection_UpsertDefaultCollection.sql @@ -14,10 +14,10 @@ AS BEGIN SET NOCOUNT ON - BEGIN TRANSACTION; + BEGIN TRANSACTION BEGIN TRY - SET @WasCreated = 1; + SET @WasCreated = 1 -- Insert Collection with DefaultCollectionOwner populated for constraint enforcement INSERT INTO [dbo].[Collection] @@ -43,7 +43,7 @@ BEGIN NULL, -- DefaultUserCollectionEmail 1, -- CollectionType.DefaultUserCollection @OrganizationUserId - ); + ) -- Insert CollectionUser INSERT INTO [dbo].[CollectionUser] @@ -61,28 +61,28 @@ BEGIN 0, -- ReadOnly = false 0, -- HidePasswords = false 1 -- Manage = true - ); + ) -- Bump user account revision dates - EXEC [dbo].[User_BumpAccountRevisionDateByCollectionId] @CollectionId, @OrganizationId; + EXEC [dbo].[User_BumpAccountRevisionDateByCollectionId] @CollectionId, @OrganizationId - COMMIT TRANSACTION; + COMMIT TRANSACTION END TRY BEGIN CATCH -- Check if error is unique constraint violation (error 2601 or 2627) IF ERROR_NUMBER() IN (2601, 2627) BEGIN -- Collection already exists, return gracefully - SET @WasCreated = 0; + SET @WasCreated = 0 IF @@TRANCOUNT > 0 - ROLLBACK TRANSACTION; + ROLLBACK TRANSACTION END ELSE BEGIN -- Unexpected error, rollback and re-throw IF @@TRANCOUNT > 0 - ROLLBACK TRANSACTION; - THROW; + ROLLBACK TRANSACTION + THROW END END CATCH END