Describe the bug
If I run migration/update it will generate a migration that uses the dropColumn and addColumn command.
Expected behavior
This causes issues with losing data. It would be better to have it use renameColumn to change the column name instead.
Additional context
Affected versions
latest version
Migration Update FIle
<?php
use yii\db\Migration;
class m211013_163356_update_table_user extends Migration
{
public function up()
{
$this->dropColumn('{{%user}}', 'password_hash');
$this->addColumn('{{%user}}', 'password', $this->string()->notNull()->defaultValue('')->after('access_token'));
}
public function down()
{
$this->dropColumn('{{%user}}', 'password');
$this->addColumn('{{%user}}', 'password_hash', $this->string()->notNull()->defaultValue(''));
}
}
Updated Migration File
<?php
use yii\db\Migration;
class m211013_163356_update_table_user extends Migration
{
public function up()
{
$this->renameColumn('{{%user}}', 'password_hash', 'password');
}
public function down()
{
$this->renameColumn('{{%user}}', 'password', 'password_hash');
}
}
Describe the bug If I run migration/update it will generate a migration that uses the dropColumn and addColumn command.
Expected behavior This causes issues with losing data. It would be better to have it use renameColumn to change the column name instead.
Additional context
Affected versions latest version
Migration Update FIle
Updated Migration File