Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>South allows you to create migrations when you first start out with a new app and the tables haven't been added to the database yet, as well as creating migrations for legacy apps that already have tables in the database. The key is to know when to do what. </p> <p>Your first mistake was when you deleted your migrations, as soon as you did that, and then ran syncdb, Django didn't know that you wanted south to manage that app anymore, so it created the tables for you. When you created your initial migrations and then ran migrate, south was trying to create tables that django already created, and thus your error.</p> <p>At this point you have two options.</p> <ol> <li><p>Delete the tables for the wall app from your database and then run <code>$ py manage.py migrate wall</code> This will run the migration and create your tables.</p></li> <li><p>Fake out the initial migration run <code>$ py manage.py migrate wall 0001 --fake</code> This will tell south that you already have the tables on the database so just fake it, which will add a row to the south_migrationhistory table, so that the next time you run a migrate it will know that the first migration has already been run.</p></li> </ol> <h2>Setting up a brand new project and no database</h2> <ol> <li>create your database</li> <li>add south to installed apps</li> <li>run syncdb, this will add the django and south tables to the database</li> <li>add your apps</li> <li>for each app run <code>python manage.py schemamigration app_name --initial</code> this will create the initial migration files for your app</li> <li>then run south migrate <code>python manage.py migrate app_name</code> this will add the tables to the database.</li> </ol> <h2>Setting up a legacy project and database</h2> <ol> <li>add south to installed apps</li> <li>run syncdb, this will add the south tables to the database</li> <li>for each of your apps run <code>python manage.py schemamigration app_name --initial</code> This will create your initial migrations</li> <li>for each of your apps run <code>python manage.py migrate app_name 0001 --fake</code> , this will fake out south, it won't do anything to the database for those models, it will just add records to the south_migrationhistory table so that the next time you want to create a migration, you are all set. </li> </ol> <h2>Setting up a legacy project and no database</h2> <ol> <li>create database</li> <li>add south to installed apps</li> <li>for each of your apps run <code>python manage.py schemamigration app_name --initial</code> This will create your initial migrations</li> <li>run syncdb, this will add any apps that don't have migrations to the database.</li> <li>then run south migrate <code>python manage.py migrate</code> this will run all migrations for your apps.</li> </ol> <p>Now that you are setup with south, you can start using south to manage model changes to those apps. The most common command to run is <code>python manage.py schemamigration app_name migration_name --auto</code> that will look at the last migration you ran and it will find the changes and build out a migration file for you. Then you just need to run <code>python manage.py migrate</code> and it alter your database for you.</p> <p>Hope that helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload