简体   繁体   English

Laravel如何删除唯一列

[英]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 我这样做是laravel.com,但出现此错误

  [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'); 尝试删除$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. 给我看你的up()函数,我可以给你更多的反馈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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