In the initial stages of my project I'm making a lot of changes to the models and thus I've ended up with a lot of south migrations being generated for my apps. Is it possible to consolidate them in any way before going to my production server to perform the migrations so I don't have like a million migrations for each app? And if so, how would I go about doing that?
So, in order to allow Django to merge the migrations for you, you should follow these steps: try executing python manage.py migrate (at this point Django will see that there are conflicts and will tell you to execute python manage.py makemigrations –merge)
South is a migration tool used with Django. There will be times when you would be adding fields to a model or changing the type of field (eg: Field was an IntegerField and you want to change it to FloatField). In such cases syncdb doesn't help and South comes to your rescue.
You could always delete the existing migrations and create a new "initial" migration.
To do this, you will need to:
./manage.py convert_to_south myapp
This will leave you with a single migration corresponding to your app's state current state.
Alternatively, you can always pack your latest migrations together:
./manage.py schemamigration myapp
This will create a new migration that will correspond to the migrations you removed.
Both of these will likely mess up your development DB.
Since this is a development environment, this is how I do it (using SQLite, see below for other SQL servers):
When using "proper" SQL servers, just keep two databases: production and development. Change project settings to point to production database instead of renaming in step 3. Also, you can skip step 4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With