Browse Source

Revert "fix(domains) Rename mixed case slugs to lowercase (#43917)"

This reverts commit b4453f0e5640e9f5a862ff314b83baaf83b08b2a.

Co-authored-by: markstory <24086+markstory@users.noreply.github.com>
getsentry-bot 2 years ago
parent
commit
b00e76c8a9

+ 1 - 1
migrations_lockfile.txt

@@ -6,5 +6,5 @@ To resolve this, rebase against latest master and regenerate your migration. Thi
 will then be regenerated, and you should be able to merge without conflicts.
 
 nodestore: 0002_nodestore_no_dictfield
-sentry: 0376_fix_org_slug_casing
+sentry: 0375_remove_nullable_from_field
 social_auth: 0001_initial

+ 0 - 41
src/sentry/migrations/0376_fix_org_slug_casing.py

@@ -1,41 +0,0 @@
-# Generated by Django 2.2.28 on 2023-01-31 20:37
-
-from django.db import migrations
-from django.db.models.functions import Lower
-
-from sentry.new_migrations.migrations import CheckedMigration
-from sentry.utils.query import RangeQuerySetWrapperWithProgressBar
-
-
-def fix_org_slug_casing(apps, schema_editor):
-    Organization = apps.get_model("sentry", "Organization")
-    query = Organization.objects.exclude(slug=Lower("slug"))
-    for org in RangeQuerySetWrapperWithProgressBar(query):
-        org.slug = org.slug.lower()
-        org.save(update_fields=["slug"])
-
-
-class Migration(CheckedMigration):
-    # This flag is used to mark that a migration shouldn't be automatically run in production. For
-    # the most part, this should only be used for operations where it's safe to run the migration
-    # after your code has deployed. So this should not be used for most operations that alter the
-    # schema of a table.
-    # Here are some things that make sense to mark as dangerous:
-    # - Large data migrations. Typically we want these to be run manually by ops so that they can
-    #   be monitored and not block the deploy for a long period of time while they run.
-    # - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
-    #   have ops run this and not block the deploy. Note that while adding an index is a schema
-    #   change, it's completely safe to run the operation after the code has deployed.
-    is_dangerous = False
-
-    dependencies = [
-        ("sentry", "0375_remove_nullable_from_field"),
-    ]
-
-    operations = [
-        migrations.RunPython(
-            fix_org_slug_casing,
-            reverse_code=migrations.RunPython.noop,
-            hints={"tables": ["sentry_organization"]},
-        )
-    ]

+ 0 - 25
tests/sentry/migrations/test_0376_fix_org_slug_casing.py

@@ -1,25 +0,0 @@
-from sentry.testutils.cases import TestMigrations
-
-
-class TestOrgSlugMigration(TestMigrations):
-    migrate_from = "0375_remove_nullable_from_field"
-    migrate_to = "0376_fix_org_slug_casing"
-
-    def setup_before_migration(self, apps):
-        self.ok_org = self.create_organization(slug="good-slug")
-        self.rename_org = self.create_organization(slug="bAdSluG")
-
-        self.has_lower = self.create_organization(slug="taken")
-        self.is_dupe = self.create_organization(slug="TakeN")
-
-    def test(self):
-        self.ok_org.refresh_from_db()
-        self.rename_org.refresh_from_db()
-
-        assert self.ok_org.slug == "good-slug"
-        assert self.rename_org.slug == "badslug"
-
-        self.has_lower.refresh_from_db()
-        self.is_dupe.refresh_from_db()
-        assert self.is_dupe.slug.startswith("taken")
-        assert self.is_dupe.slug != "taken"