Skip to content

Commit 57694aa

Browse files
authored
feat(cells) Add date_updated to organizationmapping v2 (#103915)
Redo this change as it was reverted due to gaps in the control silo deployment pipeline that didn't run migrations. This migration will have run in development environment, and once the control silo migration pipeline is fixed, I'll get a new migration number and use a `SeparateDatabaseAndState` migration to handle this scenario. Reapply "feat(cells) Add date_updated to organizationmapping (#103772)" This reverts commit 94e744c. Refs INFRENG-172
1 parent 9c1612a commit 57694aa

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ releases: 0004_cleanup_failed_safe_deletes
3131

3232
replays: 0006_add_bulk_delete_job
3333

34-
sentry: 1008_loosen_unique_title_contraint
34+
sentry: 1009_add_date_updated_to_organizationmapping
3535

3636
social_auth: 0003_social_auth_json_field
3737

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Generated by Django 5.2.8 on 2025-11-20 21:13
2+
3+
import django.db.models.functions
4+
from django.db import migrations, models
5+
6+
from sentry.new_migrations.migrations import CheckedMigration
7+
from sentry.new_migrations.monkey.special import SafeRunSQL
8+
9+
10+
class Migration(CheckedMigration):
11+
# This flag is used to mark that a migration shouldn't be automatically run in production.
12+
# This should only be used for operations where it's safe to run the migration after your
13+
# code has deployed. So this should not be used for most operations that alter the schema
14+
# of a table.
15+
# Here are some things that make sense to mark as post deployment:
16+
# - Large data migrations. Typically we want these to be run manually so that they can be
17+
# monitored and not block the deploy for a long period of time while they run.
18+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
19+
# run this outside deployments so that we don't block them. Note that while adding an index
20+
# is a schema change, it's completely safe to run the operation after the code has deployed.
21+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
22+
23+
is_post_deployment = False
24+
25+
dependencies = [
26+
("sentry", "1008_loosen_unique_title_contraint"),
27+
]
28+
29+
operations = [
30+
# This migration had to be reverted after it was merged and ran in some environments.
31+
# Clean up the previous attempt and try again
32+
SafeRunSQL(
33+
sql="""
34+
ALTER TABLE "sentry_organizationmapping" DROP COLUMN IF EXISTS "date_updated";
35+
""",
36+
reverse_sql="",
37+
hints={"tables": ["sentry_organizationmapping"]},
38+
),
39+
migrations.AddField(
40+
model_name="organizationmapping",
41+
name="date_updated",
42+
field=models.DateTimeField(
43+
db_default=django.db.models.functions.Now(),
44+
auto_now=True,
45+
db_index=True,
46+
),
47+
),
48+
]

src/sentry/models/organizationmapping.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import TYPE_CHECKING
44

55
from django.db import models
6+
from django.db.models.functions import Now
67
from django.utils import timezone
78

89
from sentry import roles
@@ -53,6 +54,8 @@ class OrganizationMapping(Model):
5354
prevent_superuser_access = models.BooleanField(default=False, db_default=False)
5455
disable_member_invite = models.BooleanField(default=False, db_default=False)
5556

57+
date_updated = models.DateTimeField(db_default=Now(), auto_now=True, db_index=True)
58+
5659
class Meta:
5760
app_label = "sentry"
5861
db_table = "sentry_organizationmapping"

0 commit comments

Comments
 (0)