Добрый день. Пожалуйста, я столкнулся с этой ошибкой в моем приложении laravel. У меня есть таблица продуктов. Я хочу добавить столбец «URL», который будет уникальным. После запуска миграции я получаю ошибку ниже. Пожалуйста, какой выход из этого? Спасибо в ожидании.
Migrating: 2020_02_03_184424_add_url_to_products
Illuminate\Database\QueryException : SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'url' (SQL: alter table `products` add `url` varchar(255) not null)
at C:\xampp\htdocs\alvinsmakeup\vendor\laravel\framework\src\Illuminate\Database\Connection.php:665
661| // If an exception occurs when attempting to run a query, we'll format the error
662| // message to include the bindings with SQL, which will make this exception a
663| // lot more helpful to the developer instead of just the database's errors.
664| catch (Exception $e) {
> 665| throw new QueryException(
666| $query, $this->prepareBindings($bindings), $e
667| );
668| }
669|
Exception trace:
1 PDOException::("SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'url'")
C:\xampp\htdocs\alvinsmakeup\vendor\laravel\framework\src\Illuminate\Database\Connection.php:459
2 PDOStatement::execute()
C:\xampp\htdocs\alvinsmakeup\vendor\laravel\framework\src\Illuminate\Database\Connection.php:459
Please use the argument -v to see more details.
Process finished with exit code 1 at 18:50:21.
Execution time: 1,796 ms.
Это моя схема таблицы
class AddUrlToProducts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function (Blueprint $table) {
//
$table->string('url')->unique();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function (Blueprint $table) {
//
$table->dropColumn('url');
});
}
}