Laravel列已存在:1060列名重复

  • 本文关键字:1060列 存在 Laravel laravel
  • 更新时间 :
  • 英文 :


我正在尝试进行此迁移,但它给了我这个错误

enter code here
<?php
use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;
class CreateUsersTable extends Migration
{
public function up()
{
//CREANDO UN MODELO PARA LOS ROLES DEL USUARIO
Schema::create('roles', function (Blueprint $table) {
$table->Increments('id');
$table->string('name')->comment('Nombre del rol del usuario');
$table->text('description');
$table->timestamps();
});
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedInteger('role_id')->default(AppRole::STUDENT);
$table->foreign('role_id')->references('id')-> on('roles');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('picture')->nullable();
//cashier columns
$table->string('stripe_id')->nullable();
$table->string('card_brand')->nullable();
$table->string('card_last_four', 4)->nullable();
$table->timestamp('trial_ends_at')->nullable();

$table->rememberToken();
$table->timestamps();
});
Schema::create('subscriptions',function (Blueprint $table) {
$table->increments('id');
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
$table->string('name');
$table->string('stripe_status');
$table->string('stripe_plan');
$table->integer('quantity');
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamps();
});
Schema::create('user_social_accounts', function (Blueprint $table) {
$table->increments('id');
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')-> on('users');
$table->string('provider');
$table->string('provider_uid');
});
}

public function down()
{
Schema::dropIfExists('users');
Schema::dropIfExists('roles');
Schema::dropIfExists('subscriptions');
Schema::dropIfExists('user_social_accounts');
}
}

给我这个错误

列已存在:1060重复的列名"stripe_id"(SQL:更改表users添加stripe_idvarchar(255(null,添加card_brandvarchar(255null,添加card_last_fourvarchar(4(null,增加trial_ends_at时间戳null(

异常跟踪:

1 PDOException::("SQLSTATE[42S21]:列已存在:1060重复的列名'stripe_id'"(C: \laragon\www\learning\vendor\laravel\framework\src\Illuminate\Database\Connection.php:459

2 PDOS语句::execute((C: \laragon\www\learning\vendor\laravel\framework\src\Illuminate\Database\Connection.php:459

收银台提供迁移功能,可将"客户列"添加到users表中。

"收银台服务提供商注册了自己的数据库迁移目录,因此请记住在安装软件包后迁移您的数据库。收银台迁移将向您的用户表中添加几列,并创建一个新的订阅表来保存您客户的所有订阅">

Laravel 6.x文档-收银台-安装

因此,这些迁移试图添加您自己添加的列。

"如果您想阻止出纳的迁移完全运行,您可以使用出纳提供的ignoreMigrations。">

如果您使用的是laravel/cashbor,它将为您添加cashbor列和订阅表的迁移。因此,您不必为此编写单独的迁移。删除出纳列和订阅的迁移,然后再次尝试迁移。

最新更新