From ad27f3d87bef6b93ded10622b71b57f715db55ba Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:46:32 +1000 Subject: [PATCH] [AC-1717] Update default values for LimitCollectionCreationDeletion (#3365) * Change default value in organization create sproc to 1 * Drop old column name still present in some QA instances * Set LimitCollectionCreationDeletion value in code based on feature flag --- .../Services/Implementations/OrganizationService.cs | 9 ++++++++- .../dbo/Stored Procedures/Organization_Create.sql | 2 +- ...2023-09-26_00_LimitCollectionCreationDeletion.sql | 12 +++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 5f05e3ca6fb8..20c39cbee732 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -57,6 +57,7 @@ public class OrganizationService : IOrganizationService private readonly IProviderUserRepository _providerUserRepository; private readonly ICountNewSmSeatsRequiredQuery _countNewSmSeatsRequiredQuery; private readonly IUpdateSecretsManagerSubscriptionCommand _updateSecretsManagerSubscriptionCommand; + private readonly IFeatureService _featureService; public OrganizationService( IOrganizationRepository organizationRepository, @@ -85,7 +86,8 @@ public OrganizationService( IProviderOrganizationRepository providerOrganizationRepository, IProviderUserRepository providerUserRepository, ICountNewSmSeatsRequiredQuery countNewSmSeatsRequiredQuery, - IUpdateSecretsManagerSubscriptionCommand updateSecretsManagerSubscriptionCommand) + IUpdateSecretsManagerSubscriptionCommand updateSecretsManagerSubscriptionCommand, + IFeatureService featureService) { _organizationRepository = organizationRepository; _organizationUserRepository = organizationUserRepository; @@ -114,6 +116,7 @@ public OrganizationService( _providerUserRepository = providerUserRepository; _countNewSmSeatsRequiredQuery = countNewSmSeatsRequiredQuery; _updateSecretsManagerSubscriptionCommand = updateSecretsManagerSubscriptionCommand; + _featureService = featureService; } public async Task ReplacePaymentMethodAsync(Guid organizationId, string paymentToken, @@ -425,6 +428,9 @@ public async Task> SignUpAsync(Organizatio await ValidateSignUpPoliciesAsync(signup.Owner.Id); } + var flexibleCollectionsIsEnabled = + _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); + var organization = new Organization { // Pre-generate the org id so that we can save it with the Stripe subscription.. @@ -462,6 +468,7 @@ public async Task> SignUpAsync(Organizatio Status = OrganizationStatusType.Created, UsePasswordManager = true, UseSecretsManager = signup.UseSecretsManager, + LimitCollectionCreationDeletion = !flexibleCollectionsIsEnabled }; if (signup.UseSecretsManager) diff --git a/src/Sql/dbo/Stored Procedures/Organization_Create.sql b/src/Sql/dbo/Stored Procedures/Organization_Create.sql index 856a58d3e814..1291e8c0a162 100644 --- a/src/Sql/dbo/Stored Procedures/Organization_Create.sql +++ b/src/Sql/dbo/Stored Procedures/Organization_Create.sql @@ -51,7 +51,7 @@ @MaxAutoscaleSmSeats INT= null, @MaxAutoscaleSmServiceAccounts INT = null, @SecretsManagerBeta BIT = 0, - @LimitCollectionCreationDeletion BIT = 0 + @LimitCollectionCreationDeletion BIT = 1 AS BEGIN SET NOCOUNT ON diff --git a/util/Migrator/DbScripts/2023-09-26_00_LimitCollectionCreationDeletion.sql b/util/Migrator/DbScripts/2023-09-26_00_LimitCollectionCreationDeletion.sql index 6e15f9c36eff..735ca36fa6d3 100644 --- a/util/Migrator/DbScripts/2023-09-26_00_LimitCollectionCreationDeletion.sql +++ b/util/Migrator/DbScripts/2023-09-26_00_LimitCollectionCreationDeletion.sql @@ -1,3 +1,13 @@ +--Dev cleanup: drop previous column name (never used in production but may be present on some QA instances) +IF COL_LENGTH('[dbo].[Organization]', 'LimitCollectionCdOwnerAdmin') IS NOT NULL +BEGIN + ALTER TABLE + [dbo].[Organization] + DROP COLUMN + [LimitCollectionCdOwnerAdmin] +END +GO + --Add column 'LimitCollectionCreationDeletion' to 'Organization' table IF COL_LENGTH('[dbo].[Organization]', 'LimitCollectionCreationDeletion') IS NULL BEGIN @@ -67,7 +77,7 @@ CREATE OR ALTER PROCEDURE [dbo].[Organization_Create] @MaxAutoscaleSmSeats INT= null, @MaxAutoscaleSmServiceAccounts INT = null, @SecretsManagerBeta BIT = 0, - @LimitCollectionCreationDeletion BIT = 0 + @LimitCollectionCreationDeletion BIT = 1 AS BEGIN SET NOCOUNT ON