我有以下数据库迁移:
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']);
});
}
};当我运行迁移时
我得到以下信息:
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▕ }我很困惑是什么导致了这个错误,以及如何去解决它。谢谢。
https://stackoverflow.com/questions/72823887
复制相似问题