我这样做是为了使我的电子邮件字段在表中唯一
。
$table->unique('email');
我试过了
public function up()
{
Schema::table('contacts', function(Blueprint $table)
{
$table->dropUnique('email');
});
}
然后,当我运行 php artisan migrate 时,我得到了这个
它告诉我它不存在,但我 100% 确定它存在。
如何编写迁移来撤消它?
最佳答案
你必须做 $table->dropUnique('users_email_unique');
To drop an index you must specify the index's name. Laravel assigns a reasonable name to the indexes by default. Simply concatenate the table name, the names of the column in the index, and the index type.
关于php - 如何编写迁移以撤消 Laravel 中的唯一约束?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30607670/