mirror of
https://github.com/bcit-ci/CodeIgniter.git
synced 2025-02-20 11:13:29 +08:00
...
parent
f00a60a3de
commit
67be6b4f50
@ -148,23 +148,31 @@ Finally, create the actual migration in a file named `001_create_songs.class.php
|
||||
|
||||
class CreateSongs extends Doctrine_Migration_Base {
|
||||
public function up() {
|
||||
$this->createTable('songs', array('title' => array('type' => 'string')));
|
||||
$this->createTable('songs', array(
|
||||
'id' => array('type' => 'integer', 'length' => 4, 'primary' => true, 'autoincrement' => true),
|
||||
'artist' => array('type' => 'string', 'length' => 255),
|
||||
'song' => array('type' => 'string', 'length' => 255)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public function postUp() {
|
||||
$migrationTest = new MigrationTest();
|
||||
$migrationTest->title = 'We Built This City';
|
||||
$migrationTest->save();
|
||||
Doctrine::loadModels(MODELS_PATH);
|
||||
Doctrine::getTable('song');
|
||||
|
||||
$song = new Song();
|
||||
$song->artist = 'Starship';
|
||||
$song->song = 'We Built This City';
|
||||
$song->save();
|
||||
}
|
||||
|
||||
|
||||
public function preDown() {
|
||||
$song = Doctrine::getTable('songs')->findOneBySong('We Built This City');
|
||||
$song->delete();
|
||||
}
|
||||
|
||||
public function down() {
|
||||
$this->dropTable('songs');
|
||||
}
|
||||
|
||||
public function postDown() {
|
||||
$migrationTest = Doctrine::getTable('songs')->findOneByTitle('We Built This City');
|
||||
$migrationTest->delete();
|
||||
}
|
||||
}
|
||||
[/code]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user