我有一个MySQL数据库,其中包含一个名为 user_level_attempt 的表。该表有一个带有['PROGRESSED', 'STOPPED', 'COMPLETED']值的ENUM类型列。我需要编写一个迁移来向该列添加另一个值(比如“PASSED”)。添加后,它看起来像这样,['PROGRESSED', 'STOPPED', 'COMPLETED', 'PASSED]。我怎么能在 Laravel 中做到这一点?我尝试了以下解决方案,但它似乎不是一个好的做法/解决方案。
/**
* Schema table name to migrate
* @var string
*/
public $set_schema_table = 'bt_user_level_attempt';
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table($this->set_schema_table, function ($table) {
$table->dropColumn('status');
});
Schema::table($this->set_schema_table, function ($table) {
$table->enum('status', ['PROGRESS', 'STOPPED', 'COMPLETED', 'PASSED'])->default('PROGRESS')->after('effective_time_spend');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table($this->set_schema_table, function …Run Code Online (Sandbox Code Playgroud)