-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make
OrganisationSubscriptionInformationCache.allowed_projects
…
… nullable (#2716)
- Loading branch information
1 parent
db1a946
commit 1b37c99
Showing
3 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
api/organisations/migrations/0046_allow_allowed_projects_to_be_null.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Generated by Django 3.2.20 on 2023-08-31 11:31 | ||
from django.apps.registry import Apps | ||
from django.db import migrations, models | ||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
|
||
|
||
def update_allowed_projects_for_all_paid_subscriptions( | ||
apps: Apps, schema_editor: BaseDatabaseSchemaEditor | ||
) -> None: | ||
organisation_subscription_information_cache_model = apps.get_model( | ||
"organisations", "organisationsubscriptioninformationcache" | ||
) | ||
organisation_subscription_information_cache_model.objects.exclude( | ||
organisation__subscription__plan="free" | ||
).update(allowed_projects=None) | ||
|
||
|
||
def reverse(apps: Apps, schema_editor: BaseDatabaseSchemaEditor) -> None: | ||
""" | ||
Set the values for the OrganisationSubscriptionInformationCache objects back to 1 (which | ||
is incorrect for paid subscriptions, but necessary to avoid IntegrityError when reversing | ||
migrations) | ||
""" | ||
|
||
organisation_subscription_information_cache_model = apps.get_model( | ||
"organisations", "organisationsubscriptioninformationcache" | ||
) | ||
organisation_subscription_information_cache_model.objects.exclude( | ||
organisation__subscription__plan="free" | ||
).update(allowed_projects=1) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("organisations", "0045_auto_20230802_1956"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="organisationsubscriptioninformationcache", | ||
name="allowed_projects", | ||
field=models.IntegerField(default=1, blank=True, null=True), | ||
), | ||
migrations.RunPython( | ||
update_allowed_projects_for_all_paid_subscriptions, reverse_code=reverse | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1b37c99
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-preview – ./frontend
flagsmith-frontend-preview-flagsmith.vercel.app
flagsmith-frontend-preview-git-main-flagsmith.vercel.app
flagsmith-frontend-production-native.vercel.app
1b37c99
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-flagsmith.vercel.app
docs.flagsmith.com
docs-git-main-flagsmith.vercel.app
docs.bullet-train.io
1b37c99
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-staging – ./frontend
flagsmith-frontend-staging-git-main-flagsmith.vercel.app
flagsmith-staging-frontend.vercel.app
staging.flagsmith.com
flagsmith-frontend-staging-flagsmith.vercel.app