Reputation: 5196
Using the migration feature in Yii2, I'am trying to add a new column called 'authorization_key'
on the table 'users'
. My up
-function is as follows:
My initial run
function was this
public function up()
{
$this->createTable( 'users', [
'id' => 'pk',
'username' => 'string UNIQUE',
'password' => 'string'
]);
}
and when I run ./yii migrate up
after ./yii migrate/create
, the table was created .
But after adding $this->addColumn('user', 'authorization_key'for', 'string UNIQUE');
, i.e.
the new up
function is
public function up()
{
$this->createTable( 'users', [
'id' => 'pk',
'username' => 'string UNIQUE',
'password' => 'string'
]);
$this->addColumn('user', 'authorization_key'for', 'string UNIQUE');
}
and I run
./yii migrate up
, it was not working and didnt create new column , but it was showing
No new migration found. Your system is up-to-date.
How can new columns in a table be added using migration or what is the error here? Am I missing some commands here?
Upvotes: 3
Views: 10264
Reputation: 136
The migration you created had been marked as done (check table 'migration' in your database). If you want to add new column to the that table you have to down the migration and run it again or create new migration.
Upvotes: 9