Skip to content

Remove replaces from squashed migrations#900

Merged
nijel merged 1 commit intopython-social-auth:masterfrom
FernandoKGA:fix/remove-replaces-from-migrations
Feb 5, 2026
Merged

Remove replaces from squashed migrations#900
nijel merged 1 commit intopython-social-auth:masterfrom
FernandoKGA:fix/remove-replaces-from-migrations

Conversation

@FernandoKGA
Copy link
Contributor

Description

This PR removes the replaces attribute from squashed migrations 0001-0005, resolving the issue where Django's migrate --prune command fails.

Fixes #899

Changes

Removed the replaces attribute from the following migration files:

  • 0001_initial.py
  • 0002_add_related_name.py
  • 0003_alter_email_max_length.py
  • 0004_auto_20160423_0400.py
  • 0005_auto_20160727_2333.py

Motivation

These squashed migrations have been in place for several years and are already applied in all production databases. According to Django's migration documentation, once a squashed migration is deployed everywhere, the replaces attribute should be removed.

The presence of these attributes prevents users from running python manage.py migrate --prune, which is necessary for:

  • Database migration cleanup
  • Managing cross-app migration dependencies
  • Performing migration reference updates in other apps

Impact

⚠️ Important Migration Requirements:

  • For existing projects: You MUST have already applied the squashed migrations (0001-0005) before upgrading to this version. If you haven't run these migrations yet, do NOT upgrade.
  • For new projects: No issues - you can use this version from the start.
  • Breaking changes: Removes the ability to migrate from pre-squashed migration state. Projects that haven't yet applied migrations 0001-0005 should upgrade to a previous version first, run migrations, then upgrade to this version.
  • Backwards compatibility: Fully maintained for projects with migrations already applied. The database schema remains unchanged.
  • Benefits: Enables proper use of Django's migrate --prune command and other migration management operations.

Given that these squashed migrations were introduced several years ago, the vast majority of installations should already have them applied.

Testing

  • Verified that python manage.py showmigrations correctly shows all migrations as applied
  • Confirmed that python manage.py migrate --prune now runs without errors

Checklist

  • Removed replaces attributes from squashed migrations
  • No database schema changes
  • Resolves the issue preventing migrate --prune usage

@FernandoKGA FernandoKGA marked this pull request as ready for review January 28, 2026 20:45
@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.30%. Comparing base (3495aeb) to head (d92bfb2).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #900      +/-   ##
==========================================
- Coverage   93.33%   93.30%   -0.03%     
==========================================
  Files          42       42              
  Lines        1350     1345       -5     
  Branches       62       62              
==========================================
- Hits         1260     1255       -5     
  Misses         67       67              
  Partials       23       23              
Flag Coverage Δ
unittests 93.30% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nijel nijel merged commit 05e8ad8 into python-social-auth:master Feb 5, 2026
10 checks passed
@nijel
Copy link
Member

nijel commented Feb 5, 2026

Merged, thanks for your contribution!

@nijel nijel self-assigned this Feb 5, 2026
@FernandoKGA FernandoKGA deleted the fix/remove-replaces-from-migrations branch February 5, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Squashed migrations still contain replaces attribute, preventing migrate --prune command

2 participants