Skip to content

Instantly share code, notes, and snippets.

@halfdan
Created February 3, 2011 21:16
Show Gist options
  • Save halfdan/810213 to your computer and use it in GitHub Desktop.
Save halfdan/810213 to your computer and use it in GitHub Desktop.
ActiveRecord\Migration - CreateTable
<?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');
}
}
<?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');
}
}
?>
@halfdan
Copy link
Author

halfdan commented Feb 4, 2011

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.

@silentworks
Copy link

Where is this Migration Class located? Is it a part of PHP Activerecord or something you are working on separately @halfdan

@halfdan
Copy link
Author

halfdan commented Jun 23, 2011

@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