Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6019345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:24:31+00:00 2026-05-23T03:24:31+00:00

During development I created many migrations, often going back and forth about how I

  • 0

During development I created many migrations, often going back and forth about how I wanted to implement something.

Now it is time to push it to production, but I am getting errors when replaying all the migrations on the virgin database.

I ended up doing the following to get it to work.

python manage.py syncdb --all
python manage.py migrate --fake

But that will not apply a data migration that I created.

Upon further thinking, I decided that I wanted to squash all my migrations into just one, when I am ready to tag this as a release version.

How can I do this? If it is not possible/recommended, then what is the prefered method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:24:32+00:00Added an answer on May 23, 2026 at 3:24 am

    It’s possible, and I’ve done it myself a few times. You basically have two methods:

    1) This is by far the easiest and preferred method. Simply, rollback your dev database to right before the first migration you want to include in the “squash”, then delete all the migrations from that one on. Finally, re-run the schemamigration management command. You’ll end up with all the migrations necessary all in one file.

    2) If for some reason you can’t do #1, it’s still technically possible, but will be much more exacting of a procedure. Literally copy and paste the contents of the forwards and backwards methods of each migration into one migration file (your lowest numbered one). That part is easy enough, but you’ll then have to also make manual modifications to the frozen models at the bottom of the file. I’ve found the best way is to simply try to run this new migration. You’ll likely get errors about such-and-such model has no attribute such-and-such. That’s a signal to go add that field to the frozen model. When the migration runs without errors, you’re golden.

    Note: Remember when you delete those old migration files, delete them with the any versioning system you’re using in mind. In other words, use git rm or svn rm, etc. If you end up with those old migrations tagging along in your release, you’ll bork your production instance. For my part, I never commit migrations until I’m ready to release my changes. You can always regenerate the migration if you lose it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During development I have to clear cache in Firefox all the time in order
During our initial development we haven't worried about scaling concerns, just getting the bare
My project has collected CSS entropy (unused classes) during its course of development. Now
What is the advantage of using bundle during iPhone development? p.s. I see many
During development (and for debugging) it is very useful to run a Java class'
I have a ListBox that during development I had the items in the ListBox
I am working on a large (100s of assemblies) asp.net application and during development
During software development, there may be bugs in the codebase which are known issues.
During a discussion about security, a developer on my team asked if there was
During a typical day programming, I implement functions in a way that I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.