首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法在Laravel迁移

无法在Laravel迁移
EN

Stack Overflow用户
提问于 2022-07-01 02:43:48
回答 4查看 67关注 0票数 0

我有以下数据库迁移:

代码语言:javascript
运行
复制
return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('metrics', function (Blueprint $table) {
            $table->id();

    });
}

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::create('metrics', function(Blueprint $table)
        {
          $table->dropIndex(['id']);
        });
    }
};

当我运行迁移时

我得到以下信息:

代码语言:javascript
运行
复制
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'metrics' already exists (SQL: create table `metrics` (`id` bigint unsigned not null auto_increment primary key, `value_string` varchar(255) null, `value_integer` int null, `value_float` double(8, 2) null, `value_date` date null, `value_boolean` tinyint(1) null, `category` varchar(255) not null, `source` varchar(255) not null, `availability` tinyint(1) not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:742
    738▕         // If an exception occurs when attempting to run a query, we'll format the error
    739▕         // message to include the bindings with SQL, which will make this exception a
    740▕         // lot more helpful to the developer instead of just the database's errors.
    741▕         catch (Exception $e) {
  ➜ 742▕             throw new QueryException(
    743▕                 $query, $this->prepareBindings($bindings), $e
    744▕             );
    745▕         }
    746▕     }

我很困惑是什么导致了这个错误,以及如何去解决它。谢谢。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72823887

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档