I am very new to YII but had an experience with php frameworks already.
I found it good and bad ass!
–
I am a fan of rails migrate and good thing YII adopted it.
While using Yii migrate I found that there is a need to define
multiple tables in the command, especially for relationships wherein
it would require a lot of tables.
I have to hack the migration core source code but i know there is a better
way to do this. so my code is available at github .com/ wcabundo /Yii-Multiple-Tables-Migrate
anyone can fork it.
To preview what the command can do, please see below.
USAGE:
./yiic migrate create test_tables --table-alias=‘tbl_user:user, tbl_project:project, tbl_connection:connection’
It will now generate
<?php
class m110705_085429_test_tables extends CDbMigration {
private $user = 'tbl_user';
private $project = 'tbl_project';
private $connection = 'tbl_connection';
public function up() {
$fields = array(
'id'=>'INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT',
'create_time'=>'DATETIME',
'update_time'=>'DATETIME',
);
$this->createTable($this->user,$fields);
$this->createTable($this->project,$fields);
$this->createTable($this->connection,$fields);
}
public function down()
{
$this->dropTable($this->user);
$this->dropTable($this->project);
$this->dropTable($this->connection);
}
}