Skip to content

Zero-downtime migration tooling; widen File.file_size to bigint (expand stage)#5986

Open
rtibbles wants to merge 3 commits into
learningequality:hotfixesfrom
rtibbles:widen_file_size_bigint
Open

Zero-downtime migration tooling; widen File.file_size to bigint (expand stage)#5986
rtibbles wants to merge 3 commits into
learningequality:hotfixesfrom
rtibbles:widen_file_size_bigint

Conversation

@rtibbles

@rtibbles rtibbles commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

Add tooling and playbook for zero downtime migrations for changing field types, e.g. int to bigint, or char to uuid - implement start of migration for file size on File object
Create reusable tooling for migration of file_size and other fields (like our CharField UUIDs to proper UUIDFields) - allow upload of files bigger than 2.1GB > int max value
Implemented with clear tooling to help ensure we implement with guardrails and clear repeatable steps.

References

Fixes #5973
Fixes #5974

Reviewer guidance

  • DB engine swap (settings.py, production_settings.py): DB backend now routes through django-pg-zero-downtime-migrations.
  • Migration 0167: nullable shadow column + concurrent index + mirror trigger — all safe DDL (the backend forces atomic=False, so the in-migration CREATE INDEX CONCURRENTLY is fine).
  • deploy-migrate runs the backfill this release. New writes dual-write via the trigger.
  • New CI step lints PR migrations against the merge-base.

AI usage

Used Claude Code to implement the tooling (safe DB backend wiring, the mirror_field dual-write trigger, the backfill_column command) and draft the runbook. I reviewed the output across several local review rounds for correctness, tightened it to Studio's conventions, and ran the test suite.

rtibbles and others added 3 commits June 23, 2026 18:33
- Safe-DDL backend: lock timeout, fail-fast, runtime unsafe-op guard
- CI linting of new migrations on pull requests
- Declarative dual-write trigger decorator (mirror_field)
- Reusable batched-backfill command (idempotent, resumable, throttled)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LfZvkigk8hdsKdEif3hzBi
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LfZvkigk8hdsKdEif3hzBi
Expand stage of the zero-downtime int->bigint widening:
- Add nullable file_size_bigint shadow column and its index (built CONCURRENTLY).
- Mirror file_size into it via the change-guarded @mirror_field trigger.
- Wire the online backfill as a commented deploy-migrate step.
- Stage the cutover and contract steps as comments on the File model.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LfZvkigk8hdsKdEif3hzBi
@rtibbles rtibbles marked this pull request as ready for review June 24, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant