addColumn("customer", "newsletter_token", "string" ); $customers = Customer::find()->all(); foreach ($customers as $customer ){ $customer->newsletter_token = Yii::$app->security->generateRandomString() . '_' . time(); $customer->save(); } } public function down() { echo "m160523_055217_add_customer_newsletter_token cannot be reverted.\n"; return false; } /* // Use safeUp/safeDown to run migration code within a transaction public function safeUp() { } public function safeDown() { } */ }