When I try and use "php artisan migrate:refresh" I get the following error.
[PDOException]
SQLSTATE[HY000]: General error: 1 table "settings" already exists
Below is my migration file. When I do migrate:refresh, it refreshes all tables up until this settings table.
Below is my migration file
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('settings', function (Blueprint $table) {
$table->increments('id');
$table->string('treatmentName');
$table->integer('numberOfReviewsShown');
$table->integer('weekAlert');
$table->integer('dayAlert');
$table->integer('weeklyRent');
$table->integer('dailyRent');
$table->integer('numberOfDrugTestsShown');
$table->integer('rentAlert');
$table->integer('availableBeds');
$table->timestamps();
});
DB::table('settings')->insert(
array(
'numberOfReviewsShown' => '5',
'treatmentName' => 'Default',
'weekAlert' => '1',
'dayAlert' => '1',
'weeklyRent' => '170',
'dailyRent' => '25',
'rentAlert' => '341',
'availableBeds' => '100',
'numberOfDrugTestsShown' => '3',
)
);
}
public function down()
{
Schema::drop('settings');
}
}
I fixed the issue. My understanding is because there was an error when trying to migrate, when I rollback since this table was not created in last migrate, rollback does not recogoinze it.
TO FIX: I put schema::drop in the up function, ran a migration which deleted it.