Skip to content

Commit

Permalink
[AC-1717] Update default values for LimitCollectionCreationDeletion (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
eliykat authored Oct 24, 2023
1 parent cd376be commit ad27f3d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/Core/Services/Implementations/OrganizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -85,7 +86,8 @@ public OrganizationService(
IProviderOrganizationRepository providerOrganizationRepository,
IProviderUserRepository providerUserRepository,
ICountNewSmSeatsRequiredQuery countNewSmSeatsRequiredQuery,
IUpdateSecretsManagerSubscriptionCommand updateSecretsManagerSubscriptionCommand)
IUpdateSecretsManagerSubscriptionCommand updateSecretsManagerSubscriptionCommand,
IFeatureService featureService)
{
_organizationRepository = organizationRepository;
_organizationUserRepository = organizationUserRepository;
Expand Down Expand Up @@ -114,6 +116,7 @@ public OrganizationService(
_providerUserRepository = providerUserRepository;
_countNewSmSeatsRequiredQuery = countNewSmSeatsRequiredQuery;
_updateSecretsManagerSubscriptionCommand = updateSecretsManagerSubscriptionCommand;
_featureService = featureService;
}

public async Task ReplacePaymentMethodAsync(Guid organizationId, string paymentToken,
Expand Down Expand Up @@ -425,6 +428,9 @@ public async Task<Tuple<Organization, OrganizationUser>> 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..
Expand Down Expand Up @@ -462,6 +468,7 @@ public async Task<Tuple<Organization, OrganizationUser>> SignUpAsync(Organizatio
Status = OrganizationStatusType.Created,
UsePasswordManager = true,
UseSecretsManager = signup.UseSecretsManager,
LimitCollectionCreationDeletion = !flexibleCollectionsIsEnabled
};

if (signup.UseSecretsManager)
Expand Down
2 changes: 1 addition & 1 deletion src/Sql/dbo/Stored Procedures/Organization_Create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
@MaxAutoscaleSmSeats INT= null,
@MaxAutoscaleSmServiceAccounts INT = null,
@SecretsManagerBeta BIT = 0,
@LimitCollectionCreationDeletion BIT = 0
@LimitCollectionCreationDeletion BIT = 1
AS
BEGIN
SET NOCOUNT ON
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ad27f3d

Please sign in to comment.