Skip to content

Commit

Permalink
fix: Align deletedproject.slug with project.slug
Browse files Browse the repository at this point in the history
Having the same length fields is important as we copy data from one
table to the other.

Fixes SENTRY-3GDK
  • Loading branch information
markstory committed Nov 4, 2024
1 parent e550f25 commit fa5595b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ hybridcloud: 0016_add_control_cacheversion
nodestore: 0002_nodestore_no_dictfield
remote_subscriptions: 0003_drop_remote_subscription
replays: 0004_index_together
sentry: 0781_add_hash_basis_to_grouphash_metadata
sentry: 0782_align_deletedproject_slug_length
social_auth: 0002_default_auto_field
uptime: 0017_unique_on_timeout
workflow_engine: 0010_detector_state_unique_group
2 changes: 2 additions & 0 deletions src/sentry/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def get_all_languages() -> list[str]:

SENTRY_APP_SLUG_MAX_LENGTH = 64

PROJECT_SLUG_MAX_LENGTH = 100

# Maximum number of results we are willing to fetch when calculating rollup
# Clients should adapt the interval width based on their display width.
MAX_ROLLUP_POINTS = 10000
Expand Down
33 changes: 33 additions & 0 deletions src/sentry/migrations/0782_align_deletedproject_slug_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.1.1 on 2024-11-04 16:07

from django.db import migrations, models

from sentry.new_migrations.migrations import CheckedMigration


class Migration(CheckedMigration):
# This flag is used to mark that a migration shouldn't be automatically run in production.
# 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 post deployment:
# - Large data migrations. Typically we want these to be run manually 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
# run this outside deployments so that we don't block them. Note that while adding an index
# is a schema change, it's completely safe to run the operation after the code has deployed.
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment

is_post_deployment = False

dependencies = [
("sentry", "0781_add_hash_basis_to_grouphash_metadata"),
]

operations = [
migrations.AlterField(
model_name="deletedproject",
name="slug",
field=models.CharField(max_length=100, null=True),
),
]
3 changes: 2 additions & 1 deletion src/sentry/models/deletedproject.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models

from sentry.constants import PROJECT_SLUG_MAX_LENGTH
from sentry.db.models import BoundedBigIntegerField, region_silo_model, sane_repr
from sentry.models.deletedentry import DeletedEntry

Expand All @@ -15,7 +16,7 @@ class DeletedProject(DeletedEntry):
is deleted, the child is also marked for deletion as well).
"""

slug = models.CharField(max_length=50, null=True)
slug = models.CharField(max_length=PROJECT_SLUG_MAX_LENGTH, null=True)
name = models.CharField(max_length=200, null=True)

organization_id = BoundedBigIntegerField(null=True)
Expand Down
3 changes: 1 addition & 2 deletions src/sentry/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from sentry.backup.dependencies import PrimaryKeyMap
from sentry.backup.helpers import ImportFlags
from sentry.backup.scopes import ImportScope, RelocationScope
from sentry.constants import RESERVED_PROJECT_SLUGS, ObjectStatus
from sentry.constants import PROJECT_SLUG_MAX_LENGTH, RESERVED_PROJECT_SLUGS, ObjectStatus
from sentry.db.mixin import PendingDeletionMixin, delete_pending_deletion_option
from sentry.db.models import (
BoundedPositiveIntegerField,
Expand Down Expand Up @@ -54,7 +54,6 @@
from sentry.users.models.user import User

SENTRY_USE_SNOWFLAKE = getattr(settings, "SENTRY_USE_SNOWFLAKE", False)
PROJECT_SLUG_MAX_LENGTH = 100

# NOTE:
# - When you modify this list, ensure that the platform IDs listed in "sentry/static/app/data/platforms.tsx" match.
Expand Down

0 comments on commit fa5595b

Please sign in to comment.