Reputation: 83
I have in my database enum list ('name_1','name_2','name_3'). Also I have create Model and Controller.
Later I have change enum list to ('new_name_1','new_name_2','new_name_3'). But in form I still see old list ('name_1','name_2','name_3').
What must I do to refresh enum list?
Thank you.
Upvotes: 0
Views: 1182
Reputation: 317
Rather simple. As @scaisEdge commented, you need to execute an update query.
On a migration you can execute the following code to edit an ENUM column on Yii2.
public function safeUp()
{
$query = "ALTER TABLE TABLENAME MODIFY tipo ENUM('VALUE1','VALUE2','VALUE4','VALUE5') default 'VALUE1'";
$this->execute($query);
}
In this case we are also giving the default value of VALUE1, in case that we don't provide a value.
Remember that you can create the migration from the console using the yii command.
./yii migrate/create add_enum_value_to_table
The migration should be on the console folder, under migrations.
Hope that it helps !
Upvotes: 1
Reputation: 133370
You should use Alter Table Modify
ALTER TABLE your_db.your_table
MODIFY Your_enum_col ENUM('new_name_1','new_name_2','new_name_3');
Upvotes: 1