0
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?

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
CloudSeph
  • 863
  • 4
  • 15
  • 36

1 Answers1

2

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;');
Ed209
  • 821
  • 5
  • 8