简体   繁体   中英

Laravel How can I remove unique column

This is mine

public function down()
{
    Schema::table('customer_plans', function (Blueprint $table) {
        $table->dropUnique('customer_plans_code_unique');
        $table->string('code',255)->change();
        $table->string('name',255)->change();
    });
}

I do this as laravel.com but i got this error

  [PDOException]
  SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP   'customer_plans_code_unique'; check that column/
  key exists

Anyone knows this error, please tell me! Thanks for reading!

Try removing $table->dropUnique('customer_plans_code_unique'); from your code.

Without seeing the rest of the code I can't tell if having that line is important or not, but it's definitely the reason you're seeing the error.

Show me your up() function and I can give you more feedback.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM