python manage.py convert_to_south myapp

python manage.py schemamigration newappname --initial

python manage.py

schemamigration newappname --auto

python manage.py migrate appname

python manage.py migrate

Hi there guys and we're here to talk about migrations today. My app grown to complex app with profiles, social registration permits and so on. First time I've decided to make myself a simple app. Now it became complex enough and contains enough code to need code comments :). Anyway Migrations is a process anybody someday will need. I thought it's hard to learn or understand, but it's not.Main point is that you:- save your current database tables structure- change your model tables- scan for differences and create script- then write changes to your database with automatically generated python script.Sound's simple? I't not all so simple in fact. App that you need to learn is Django-south . Its main objectives are to provide a simple, stable and database-independent migration layer to prevent all the hassle schema changes over time bring to your Django applications. It has quite understandable tutorial here So if you're tired of ALTER'ing your tables and writing code to python Sqlite console or editing raw SQL, go get yourself a copy of south. It's an app that IMHO everybody should use/hear/understand.It is meant to change old one and quite simple command 'manage.py syncdb' someday. For now go get yourself this tool and learn to use it. It took me about half an hour to understand basics.. So it's not hard (at first) :).Brief look at usage:Use pip/easy_install script or simply put 'south' dir to your project root dir.Addto yourdictionary.you need to make syncdb after that. Another way wo will get an error with future commands.Use commandto convert your app from syncdb ready to south migratable. Or you can runto add south migrations ability to your new app. In general it will create directory 'migrations' inside your app directory.. I dont think you need separate stop here. But... Just in case add some field to your django model like bollean or text and/or edit your existing field rather by adding 'null=True' for e.g.It can be done by commandto create your migration script. you can check it in your app's 'migrations' dir. It has numbers in the beginning with migration number.It is done by commandor even without an app name:to migrate all apps. Thats it.Hope you'll never use 'syncdb' again for complex tasks like this. I'm adding it to my base developer tools. And you?