Paul Basenko
Paul Basenko

Reputation: 1015

Yii1 set the default value for DB column in migration

I support the Yii 1.1.14 application and I have to add the new column into my database table in migration file. I use the next:

$this->addColumn('table', 'columnName', 'varchar(100)');

How can I set the default value for this column? And, also, I want to place the column after the concrete one.

Or, maybe, should I use the another method?

Thanks.

Upvotes: 1

Views: 1866

Answers (1)

Hector
Hector

Reputation: 68

The easiest way is:

$this->addColumn('table', 'columnName', "varchar(100) DEFAULT 'my default string'");

Upvotes: 2

Related Questions