By specifying the string length in Yii migration

I want to create a migration, the up method of which will execute the create_table function.

For instance:

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 to specify field length in migration? For instance. What would I write if I need to indicate that the length of the header field should be 100.

+3
source share
1 answer

! , , . , ?

public function up()
{
    $this->createTable('tbl_news', array(
        'id' => 'pk',
        'title' => 'varchar(20) NOT NULL',
        'content' => 'text',
    ));
}

, , , , !

+5

All Articles