I have the following database migration:
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']);
});
}
};
when i run the migration then
I get the following:
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▕ }
I am confused as to what is causing the error and how to go about solving it. Thank you.