Conversation
#982 makes new uploads land at sounds/<uuid>.<ext>, but the rows that predate it still point at files stored under the name their uploader chose — which are the ones actually exposed. #699 asked for a data migration. This is a management command instead: a migration renames live S3 objects inside a deploy, cannot be resumed after a partial run, and offers no way to see what would change first. The command is idempotent, so resuming is just running it again. It writes the new object, points the row at it, then deletes the old one, so an interruption leaves an orphan rather than a row pointing at nothing. It takes --dry-run and --limit, backfills file_name_original when empty, and isolates per-row failures so one unreadable object cannot abort the batch. Closes #991 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HXUw7kyELDu8ycGQxtaFbb
This branch has not been deployed
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.
Description
#982 makes new sound uploads land at
sounds/<uuid>.<ext>. This handles the rows that predate it, which still point at files stored under the name their uploader chose — the ones actually exposed today.#699 asked for a data migration and I'd recommend against it: a migration renames live S3 objects inside a deploy, cannot be resumed after a partial run, and gives no way to see what would change before it changes.
python manage.py backfill_sound_filenamesinstead.Resolves (Issues)
Closes #991
How it behaves
sounds/<32 hex>[.ext]are skipped, and a clean run reports "Nothing to do".--dry-runlists everyold -> newwithout touching storage or the database.--limit Nso the first batch can be small and inspected.file_name_originalfrom the old key when it's empty, so the original name is preserved as Save media content with random names #699 asks. Rows that already have it are left alone.General tasks performed
src/core/management/commands/backfill_sound_filenames.py.src/core/tests/test_backfill_sound_filenames.py— 8 tests: the rename itself, content surviving the move, the old object being removed,file_name_originalpreserved, a second run being a no-op,--dry-runchanging nothing,--limitstopping early, and one failing row not aborting the batch.Before running it in production
This moves live files, so it wants a human deciding when: rehearse with
--dry-run, then a small--limitbatch, then the rest in a quiet window. Nothing here schedules itself.Verification: full suite
pytest src/core src/users src/blogpasses — 285 passed.ruff format --diff src/clean, zeroI001, no pending migrations.Have you confirmed the application builds locally without error? See here.
🤖 Generated with Claude Code
https://claude.ai/code/session_01HXUw7kyELDu8ycGQxtaFbb
Generated by Claude Code