IvanCloud IvanCloud - 6 months ago 20
MySQL Question

how to duplicate column a data to column b using yii migration

alter table user add column join_date datetime;
UPDATE user SET join_date = date_created;

By using the code above, I am able to add a new column to the table and set join_date column to have same data as those in date created. How can i perform this action using yii2 migration?


Just add it a two entries in your up() function

$this->addColumn('user', 'join_date', $this->dateTime());
$this->execute('update user set join_date = date_created;');