I wish to create a migration whose up method will execute the create_table function.
For example :
class m101129_185401_create_news_table extends CDbMigration { public function up() { $this->createTable('tbl_news', array( 'id' => 'pk', 'title' => 'string NOT NULL', 'content' => 'text', )); } public function down() { $this->dropTable('tbl_news'); } }
How do I specify the length of a field in the migration ? Eg. What would I write if I have to specify that length of the title field should be 100 .
Hey! I believe this was an addition they did last year. I havent tried it, but doesn't this work?
public function up()
{
$this->createTable('tbl_news', array(
'id' => 'pk',
'title' => 'varchar(20) NOT NULL',
'content' => 'text',
));
}
Also, in this site you'll find information which can be helpful, as well as here. Good luck with this!