我正在尝试通过这样做来修改现有迁移:
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 上不是“唯一的”
你能帮我吗 ?
Illuminate\Database\QueryException : SQLSTATE[42S21]: Column already exists: 1060 Nom du champ 'shortned' déjà utilisé (SQL: alter table `urls` add `shortned` varchar(255) not null)
这是我收到的错误
浮云间
明月笑刀无情
繁星coding