I would do this to make my email field unique in the table.

$table->unique('email');

我试过了

public function up()
{
    Schema::table('contacts', function(Blueprint $table)
    {
        $table->dropUnique('email');
    });
}

然后,当我运行php artisan migrate时,我得到了这个

在此处输入图像描述

It tell me that it's not there, but I'm 100% sure that it's there.

在此处输入图像描述

How do write a migration to undo that ?

推荐答案

你得打$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.

Laravel相关问答推荐

Laravel Livewire与自定义JS有关的多姆问题

为什么Laravel在API请求时返回BadMethodCallException?

在postgres/mysqlс中,我可以定义基于json字段的唯一索引吗?

如何提取每组 groupBy 查询的唯一值?

Laravel 验证 - 不同的属性规范

Laravel Livewire 组件在刷新后不会自动刷新/重新加载

Laravel:在失败时处理 findOrFail()

允许的内存大小 134217728 字节用尽(试图分配 20480 字节) Laravel

克隆后设置 Laravel 项目

Laravel 查询构建器 - 如何按别名分组,或进行原始 groupBy

如何使用 laravel eloquent 获得select count(*) group by

Laravel:每当我返回一个模型时,总是返回一个与它的关系

使用数据库用户提供程序时如何在 Laravel 中创建密码重置方法

在 Laravel 中生成随机数

如何使用命令行手动运行 laravel/lumen 作业(job)

Laravel 验证:数字和整数之间的区别?

如何在 Laravel 测试中禁用选定的中间件

Laravel 4 - 文件上传

Laravel 5 Illuminate\Http\Request 的方法不允许静态调用

有没有办法让表名自动添加到 Eloquent 查询方法中?