diff --git a/migrations_lockfile.txt b/migrations_lockfile.txt index d7939931969a1f..0f467c75f31550 100644 --- a/migrations_lockfile.txt +++ b/migrations_lockfile.txt @@ -5,7 +5,7 @@ ahead of you. To resolve this, rebase against latest master and regenerate your migration. This file will then be regenerated, and you should be able to merge without conflicts. -jira_ac: 0001_initial +jira_ac: 0002_rm-db-constraint-jira-tenant nodestore: 0002_nodestore_no_dictfield sentry: 0227_backfill_visits social_auth: 0001_initial diff --git a/src/sentry_plugins/jira_ac/migrations/0002_rm-db-constraint-jira-tenant.py b/src/sentry_plugins/jira_ac/migrations/0002_rm-db-constraint-jira-tenant.py new file mode 100644 index 00000000000000..10eb144a7523c1 --- /dev/null +++ b/src/sentry_plugins/jira_ac/migrations/0002_rm-db-constraint-jira-tenant.py @@ -0,0 +1,47 @@ +# Generated by Django 2.1.15 on 2021-09-01 17:44 + +import django.db.models.deletion +from django.db import migrations + +import sentry.db.models.fields.foreignkey + + +class Migration(migrations.Migration): + # This flag is used to mark that a migration shouldn't be automatically run in + # production. We set this to True for operations that we think are risky and want + # someone from ops to run manually and monitor. + # General advice is that if in doubt, mark your migration as `is_dangerous`. + # Some things you should always mark as dangerous: + # - Large data migrations. Typically we want these to be run manually by ops so that + # they can be monitored. Since data migrations will now hold a transaction open + # this is even more important. + # - Adding columns to highly active tables, even ones that are NULL. + is_dangerous = False + + # This flag is used to decide whether to run this migration in a transaction or not. + # By default we prefer to run in a transaction, but for migrations where you want + # to `CREATE INDEX CONCURRENTLY` this needs to be set to False. Typically you'll + # want to create an index concurrently when adding one to an existing table. + # You'll also usually want to set this to `False` if you're writing a data + # migration, since we don't want the entire migration to run in one long-running + # transaction. + atomic = True + + dependencies = [ + ("jira_ac", "0001_initial"), + ] + + operations = [ + migrations.AlterField( + model_name="jiratenant", + name="organization", + field=sentry.db.models.fields.foreignkey.FlexibleForeignKey( + blank=True, + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="jira_tenant_set", + to="sentry.Organization", + ), + ), + ] diff --git a/src/sentry_plugins/jira_ac/models.py b/src/sentry_plugins/jira_ac/models.py index bda80d2f99f84f..30f47479752670 100644 --- a/src/sentry_plugins/jira_ac/models.py +++ b/src/sentry_plugins/jira_ac/models.py @@ -10,7 +10,11 @@ class JiraTenant(Model): __include_in_export__ = False organization = FlexibleForeignKey( - "sentry.Organization", null=True, blank=True, related_name="jira_tenant_set" + "sentry.Organization", + null=True, + blank=True, + related_name="jira_tenant_set", + db_constraint=False, ) client_key = models.CharField(max_length=50, unique=True) secret = models.CharField(max_length=100)