Changes between Version 5 and Version 6 of Tutorial


Ignore:
Timestamp:
12/07/08 15:09:13 (5 years ago)
Author:
andrew
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Tutorial

    v5 v6  
    131131See how it's autodetected the model, and made the migration for us? Isn't that helpful? 
    132132 
     133== Columns, Columns, Everywhere! == 
     134 
     135Of course, most of your work won't be adding new tables, but rather new columns. As of version 0.4/revision [109], South has an `--add-field` option to `./manage.py startmigration`. 
     136 
     137Like the `--model` example above, you call startmigration with an app and migration name: 
     138 
     139{{{ 
     140./manage.py startmigration app_name add_foo --add-field MyModel.foo 
     141}}} 
     142 
     143Note that you must provide the field name as `ModelName.field_name`, since South won't know what model you want otherwise! You should also have already written that column's definition in models.py. 
     144 
     145As with --model, you can use --add-field many times in a single call if you want to add a lot of columns: 
     146 
     147{{{ 
     148./manage.py startmigration mitest some_cols --add-field user.age --add-field user.profile --add-field post.user 
     149}}} 
     150 
     151(also note here that you're free to write the model class names in lowercase; they're actually stored that way in Django) 
     152 
    133153== All In One == 
    134154 
     
    161181Some things you might want to try: 
    162182 
    163  * Writing a migration which adds a new column to a table (and removes it when rolled back). The [wiki:DatabaseAPI database api documentation] might help you here. 
    164  
    165183 * Adding a new migration with the wrong number - e.g. another 0002 migration when you already have a 0003 (just rename a 0004 if you use createmigration and it makes one). The resulting problem, and the resolutions, are discussed in [wiki:CommandReference#ConflictResolution the command reference].