1

我想将新的枚举列添加statuscustomers表中。但是当我尝试运行迁移时,我得到了这个错误:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'status' in 'where clause' (SQL: select * from `customers` where `customers`.`deleted_at` is null and `status` = 1)  

  [PDOException]                                                                     
  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'status' in 'where clause'  

移民:

 public function up()
{
    Schema::table('customers', function (Blueprint $table) {
        $enum = [
            'activated' => 1,
            'deactivated' => 0
        ];
        $table->enum('status', $enum);
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::table('customers', function (Blueprint $table) {
        $table->dropColumn('status');
    });
}
4

1 回答 1

0

您的枚举值不应是关联数组

$enum = ["activated","deactivated"];
于 2016-03-11T16:27:11.733 回答