Trac

Changeset 4606 for trunk/manual

Show
Ignore:
Timestamp:
06/30/08 15:51:03 (5 months ago)
Author:
bascht
Message:

- added doc for a little workaround when migrating models with changed attributes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/manual/docs/en/migration.txt

    r3821 r4606  
    160160 
    161161If you prefer the one operation per migration, you may be starting at step 9 or 30 or who knows. If you have no existing tables or data that you care to keep, you can drop all your existing tables and call the migration function to create all your initial tables. 
     162 
     163If you had to migrate a few steps down, you might get stuck between two migration steps if your model is out of sync with your table. 
     164Assume that migration step 3 adds a new attribute to your model - and step 2 tries to access that model, you cannot migrate to step 3, because the table doesn't know about the new attribute:  
     165<code type="php"> 
     166$migration = new Doctrine_Migration('/path/to/migration_classes'); 
     167 
     168// Current version is 3 
     169echo $migration->getCurrentVersion(); // 3 
     170 
     171$migration->migrate(0); // takes you from 3 to 0 
     172$migration->migrate(3); // should take you from 0 to 3 but might throw an error if your model is out of sync 
     173 
     174echo $migration->getCurrentVersion(); // 1 
     175</code> 
     176 
     177A simple workaround is to comment out the new attribute in your model file, migrate up stepwise and uncomment the attribute, when you're done.    
     178