迁移过程中不要在我的桌子上放置“唯一”

问题描述 投票:0回答:1

我正在尝试通过执行以下操作来修改现有的迁移:

c:\wamp64\www\urlshortner>php artisan make:migration add_unique_to_shortened_on_urls_table_--table=urls

我将此代码添加到迁移文件中:

   public function up()
{
    Schema::table('urls', function (Blueprint $table) {
        $table->unique('shortned');
    });
}

我运行了PHP artisan migrate命令,但是该字段在MySQL上不是“唯一”

您能帮我吗?

php laravel
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.