Wizard
Wizard

Reputation: 11265

Yii default coll value in migration

$this->addColumn('table_name','column_name','type'); 

How to add int type column with default value 0 ? There is not params for this.

Upvotes: 0

Views: 455

Answers (1)

Ali MasudianPour
Ali MasudianPour

Reputation: 14459

You can write it in type parameter like below:

$this->addColumn('table_name','column_name','integer default 0');

Or if you use createTable method, you can do like below:

$this->createTable('tblname', array(
            'id' => 'pk',
            'age' => 'integer default 0',
            ...

Upvotes: 1

Related Questions