Changeset 3923
- Timestamp:
- 03/02/08 05:59:03 (16 months ago)
- Location:
- branches/0.10/manual/docs/en
- Files:
-
- 2 modified
-
migration.txt (modified) (4 diffs)
-
schema-files.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/manual/docs/en/migration.txt
r3921 r3923 62 62 public function dropTable($tableName) 63 63 public function renameTable($oldTableName, $newTableName) 64 public function createConstraint($tableName, $constraintName, array $definition) 65 public function dropConstraint($tableName, $constraintName, $primary = false) 66 public function createForeignKey($tableName, array $definition) 67 public function dropForeignKey($tableName, $fkName) 64 68 public function addColumn($tableName, $columnName, $type, array $options = array()) 65 69 public function renameColumn($tableName, $oldColumnName, $newColumnName) … … 72 76 +++ Altering Data 73 77 74 You can alter table directly in your up() and down() methods like you normally would by creating new model instances and calling save() or creating queries and deleting data. 78 Sometimes you may need to alter the data in the database with your models. Since you may create a table 79 or make a change, you have to do the data altering after the up() or down() method is processed. We have 80 hooks in place for this named preUp(), postUp(), preDown(), and postDown(). Define these methods and 81 they will be triggered after the migration version is executed. 75 82 76 83 <code type="php"> … … 80 87 public function up() 81 88 { 82 // Add new user 83 $user = new User(); 84 $user->loginname = 'jwage'; 85 $user->save(); 89 $this->createTable('migration_test', array('field1' => array('type' => 'string'))); 86 90 } 87 91 92 public function postUp() 93 { 94 $migrationTest = new MigrationTest(); 95 $migrationTest->field1 = 'test'; 96 $migrationTest->save(); 97 } 98 88 99 public function down() 89 100 { 90 // Delete the user we added in the up 91 $query = new Doctrine_Query(); 92 $query->delete('User')->from('User u')->where('u.loginname = ?', 'jwage')->execute(); 93 101 $this->dropTable('migration_test'); 102 } 103 104 public function postDown() 105 { 106 $migrationTest = Doctrine::getTable('MigrationTest')->findOneByField1('test'); 107 $migrationTest->delete(); 94 108 } 95 109 } … … 107 121 echo $migration->getCurrentVersion(); // 0 108 122 </code> 123 124 125 This functionality is allow allowed from the Doctrine command line interface. -
branches/0.10/manual/docs/en/schema-files.txt
r3922 r3923 14 14 defaults. Below is an example of schema taking advantage of all the shorthand features. 15 15 16 <code type=" php">16 <code type="yaml"> 17 17 --- 18 18 detect_relations: true … … 37 37 Here is the none short hand form of the above schema. 38 38 39 <code type=" php">39 <code type="yaml"> 40 40 --- 41 41 detect_relations: true