Repository navigation
chore(releases): stop dual-writing release new_id - #127438
Merged
Merged
Conversation
Drops the id pre-claiming that only existed to fill `new_id` in the same INSERT, and takes the column out of model state. It stays in Postgres for app servers still on the previous release; the drop follows in a later PR.
Contributor
|
This PR has a migration; here is the generated SQL for for --
-- Alter field new_id on release
--
ALTER TABLE "sentry_release" ALTER COLUMN "new_id" DROP NOT NULL;
--
-- Moved release.new_id field to pending deletion state
--
-- (no-op) |
wedamija
approved these changes
Oct 14, 2026
joshuarli
added a commit
that referenced
this pull request
Oct 14, 2026
…127468) `migrations-drift` has failed on every run for the last 100 runs (back to Sep 30), including on PRs that don't touch the drifting tables. The check compares a database built by running migrations with one built from squashed migrations. Step 1 of a safe deletion (`SafeRemoveField` / `SafeDeleteModel` with `DeletionAction.MOVE_TO_PENDING`) takes a field or model out of the migration state but leaves it in the database until a later `DELETE` migration drops it. The squashed schema never has it, so the check fails for as long as any deletion is in flight. Its own output already says "drift due to step 1 of deletion is normal". On current master that's `sentry_release.new_id`, which #127438 moved to pending deletion. **Fix:** a new `tools/migrations/drop_pending_deletions.py` reads `pending_deletion_models` / `pending_deletion_fields` from `SentryProjectState` and applies the `DELETE` half of each one, the same way `SafeRemoveField` / `SafeDeleteModel` would: - scalar fields: `ALTER TABLE ... DROP COLUMN` - many-to-many fields and models: their auto-created through tables are dropped with them; explicit `through` models are left alone unless they're pending deletion themselves - through tables are dropped before the tables they join, so nothing needs `CASCADE`. There's no `CASCADE` or `IF EXISTS`, so an unexpected dependent object or a missing table fails the step instead of being silently dropped or skipped - each database only gets the statements the router would migrate there The workflow runs it right before capturing `schema-before`, and now also triggers on changes to the helper. **Checked locally against master (`79af5a0d`), following the workflow's steps:** - Without the new step: drift on `sentry_release.new_id`, the same failure CI shows. - With it: the step runs `ALTER TABLE "sentry_release" DROP COLUMN "new_id"` and `tools.migrations.compare` reports no drift. - `tests/sentry/new_migrations/test_drop_pending_deletions.py` builds real tables for a scalar field, an auto-created and an explicit-through M2M field, a model with an M2M, and unrelated models, then checks exactly what's dropped and what's kept. 4 of its 5 tests fail against the previous version of the helper. It lives under `tests/sentry` because it needs the test database; `tests/tools` runs without sentry installed. - `ruff`, `mypy`, `flake8`, `actionlint` and the workflow schema check pass. <!-- junior-request-attribution:start --> via @joshuarli. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC8V02RHC7%3A1791911755.006269 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AC8V02RHC7%3A1791911755.006269) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC8V02RHC7%3A1791911755.006269/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Joshua Li <14209781+joshuarli@users.noreply.github.com>
3 tasks done
ldelvoye
added a commit
that referenced
this pull request
Oct 15, 2026
resolves INFRENG-673 Drops the old int4 `new_id` column from `sentry_release`, the last step of widening `release.id` to int8. 1211 already moved it to pending, so nothing in the app reads or writes it. Please hold the merge until #127438 has finished deploying everywhere.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves INFRENG-672
Removes the
new_iddual-write onReleaseand takes the column out of Django's model state.The early id reservation in
save()andbulk_createonly existed sonew_idcould go in the same INSERT, so it goes too, andparse_semver_pre_saveis back to checkinginstance.id. The migration makesnew_idnullable before the state-onlySafeRemoveField, since it refuses a non-null column without adb_default; the column stays in Postgres for servers on the previous release and is dropped in INFRENG-673.