Yii2 transition add new column to table
Using the migration feature in Yii2, I am trying to add a new named column 'authorization_key'
to the table 'users'
. My up
-function is this: My original function run
was this
public function up()
{
$this->createTable( 'users', [
'id' => 'pk',
'username' => 'string UNIQUE',
'password' => 'string'
]);
}
and on startup ./yii migrate up
after the ./yii migrate/create
table was created.
But after adding $this->addColumn('user', 'authorization_key'for', 'string UNIQUE');
, i.e. new up
function
public function up()
{
$this->createTable( 'users', [
'id' => 'pk',
'username' => 'string UNIQUE',
'password' => 'string'
]);
$this->addColumn('user', 'authorization_key'for', 'string UNIQUE');
}
and I ran
./yii migrate up
it didn't work and didn't create a new column but it was showing
No new migration found. Your system is up-to-date.
How do I add new columns to a table using migration or what is the error here? Am I missing some commands here?
source to share