2016-04-08 36 views
0

这是我的Laravel如何删除唯一列

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(); 
    }); 
} 

我这样做是因为laravel.com,但我得到这个错误

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

任何人都知道这个错误,请告诉我! 感谢您的阅读!

回答

2

尝试从您的代码中删除$table->dropUnique('customer_plans_code_unique');

没有看到代码的其余部分,我不知道该行是否重要,但这绝对是您看到错误的原因。让我看看你的up()函数,我可以给你更多的反馈。

+0

只是'$ table-> unique('code',50);'in up()。谢谢! –

+1

在这种情况下,只有'$ table-> dropUnique('code');'应该在你的'down()'函数中。另外,如果你发现我的答案有帮助,如果你愿意,我会很感激。 –

+1

非常感谢!这行得通 –