I have read that one should flatten (South) migrations before pushing new code to production. What does "flatten migrations" mean, why is it recommended, and how is it done in South?
1 Answers
What flattening migrations means is basically just chunking all of the migrations together as to reduce runtime of the migrations when migrations grow fairly large. It's possible but not recommended since you'll be losing all of your migration history effectively making each and every migration you run start from 0.
I haven't read anywhere that flattening is "recommended" so I can't give you that piece of advice, if you have a link I'd be happy to read it.
I have read that Ruby on Rails have this functionality but it isn't recommended there either.
Consider these questions first:
- Is this something that you really want? You would lose all history.
- It would lead to migration down to version 0 and then back up again, this would be done often
If this is done to hinder any missing or out of order migrations I would use
python manage.py schemamigration myapp --merge
or last but not least update the latest migration using --update
I found this question whilst googling and thought it'd be good for reference, it in turn contains links to 4 other questions.

- 1
- 1

- 45,354
- 16
- 98
- 92
-
2I read the following on the new two scoops django book (beta): "While working on a Django app, flatten migration(s) to just one before pushing the new code to production. In other words, commit “just enough migrations” to get the job done." However, they also say: "Don't Remove Migrations From Existing Projects In Production" – Derek Mar 03 '13 at 07:01
-
2Ah, yes, i believe they are referring to "flatten" as a concept and not a method to work. However what they can be referring to as well is that you should try to compose your migrations into one file before pushing it to production, instead of pushing let's say 15 different files from 9 different persons. I'm not sure that it's the best, I wouldn't want that but, hey, to each their own. – Henrik Andersson Mar 03 '13 at 07:07