Created
February 3, 2011 21:16
-
-
Save halfdan/810213 to your computer and use it in GitHub Desktop.
ActiveRecord\Migration - CreateTable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CreateUsers extends ActiveRecord\Migration { | |
public function up() { | |
$this->create_table('users', array( | |
// <field> => array(<type>, <length>, <nullable>) | |
'name' => array('varchar', 12, FALSE), | |
'email' => array('varchar', 255, FALSE) | |
)); | |
} | |
public function down() { | |
$this->drop_table('users'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AddTableUsers extends ActiveRecord\Migration\Base { | |
public function up() { | |
$columns = array( | |
'name' => array( | |
'type' => 'string', | |
'length' => 12, | |
'notnull' => TRUE | |
), | |
'email' => array( | |
'type' => 'varchar', | |
'length' => 25 | |
) | |
); | |
$this->createTable('users', $columns, array('extra' => "ENGINE=INNODB")); | |
} | |
public function down() { | |
$this->dropTable('users'); | |
} | |
} | |
?> |
Where is this Migration Class located? Is it a part of PHP Activerecord or something you are working on separately @halfdan
@silentworks: I've been working on this for a while. Not sure if I'll finish it any time soon.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes certainly. I just added a new proposal. It looks quite similar to what the guys from Doctrine had in version 1.2. We can of course define default values, that's what I had in mind anyway.