how to add new column with default value via schema? I make as this:
$this->addColumn('users', 'email_notification', Schema::TYPE_SMALLINT . ' AFTER auth_key DEFAULT 0 ');
but it's not working..
Thanks
Try this, type
parameter accepts ColumnSchemaBuilder
as well.
$this->addColumn('users', 'email_notification', $this->smallInteger()->defaultValue(0));
Make sure you 'use' the yii\db\Schema
use yii\db\Schema;
use yii\db\Migration;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With