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 6026681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:28:51+00:00 2026-05-23T04:28:51+00:00

I’m curious as to how other Django devs manage their database migrations with South

  • 0

I’m curious as to how other Django devs manage their database migrations with South when developing with multiple code branches. Let me give a sample scenario.

Say for example you start you development with your main trunk. You create Branch A from the trunk. At this point, the last migration version for app_1 is 0010.

Then you create a migration for app_1 in the trunk that creates a migration file 0011_add_name_column. Meanwhile, in branch A, another developer creates a different migration file for the same app_1 in branch A: 0011_increase_value_column_size.

Branch A eventually gets merged back to trunk. When this happens, say last migration version in app_1 in Branch A is 0020 and in the trunk the last version is 0018, and they’re all different migrations. As you can see, the state of the migration files are messed up since version 0011, when the branch was forked from trunk.. and they’re all in conflicts upon merging.

According to South’s tutorial, the only way to handle this case is to manually resolve all the conflicts. However, this is not really a desired solution if the amount of conflicts are significant. How do you typically handle this situation, or even to avoid it in the first place?

  • 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-23T04:28:52+00:00Added an answer on May 23, 2026 at 4:28 am

    Well, the answer to this is not very straightforward.

    TL;DR update:
    In most cases, if we are talking a Trunk <-> Branch workflow I would probably

    1. “Compress” new migrations from Branch A into a single migration (or least possible)
    2. Merge all trunk changes/migrations to Branch A.
    3. Rename Branch A migrations to 0019 and so on.
    4. Now merge to trunk.

    More detail

    First of all, it doesn’t matter if you have multiple migrations with same prefix (i.e. 0011) from merging different branches, as long as they don’t modify the same models. Then you can simply run migrate with the --merge option to apply out of order migrations.

    But if you have two different “migration paths” from 0011 -> 0018 and 0011 -> 0020 for the same app, even if they don’t touch the same models, that’s not very pretty. I think it’s likely that either:

    1. Those branches have been separated for a very long time and there’s a large disparity in the 2 schemas. There are 2 possible situations here:

      • They don’t touch the same models (i.e they don’t “intersect”): You can just apply them out of order with --merge, however it’s very likely the affected models should better belong to 2 separate apps instead.

      • They do touch the same models (which I assume it’s probably your case): I have to concur with @chrisdpratt here, that it’s best to avoid this situation altogether by coordinating/splitting up work better. But even in this case, especially if you have only schema migrations, and you don’t do some obviously conflicting schema migrations in the two branches (a stupid example would be adding a field with the same name to same model in 2 different migrations), it’s pretty likely that you can just apply the migrations (or at least most of them) out of order with --merge without problems. In many cases the order of the schema migrations won’t matter even if they affect the same model, you do need to check this manually however. And when it’s an issue, you’ll just have to change their numbering, there’s no automatic way around it.

    2. You generate a new schema migration for every little schema change: There’s nothing wrong with this during development, but once the feature is complete (ready for merging) the migrations should be “compressed” into a single migration (or at least less migrations if there are a lot of changes with some logical grouping, or if you also have data migrations). On dev environment which is already on latest migration, it’s simple to just do

      • ./manage.py migrate myapp 0010 –fake
      • delete migrations 0011-0018
      • ./manage.py schemamigration myapp schema_changes_for_new_feature_x –auto
      • ./manage.py migrate myapp 0011 –fake –delete-ghost-migrations

    Another thing is, that after merging between two branches with different migrations, you’ll often need to create a mergefix schema migration (with empty forwards/backwards) methods, to record the combined state in the “frozen” models (otherwise South will think there are outstanding schema changes)

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a reasonable size flat file database of text documents mostly saved in
I have this code to decode numeric html entities to the UTF8 equivalent character.
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.