Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

siewlon6093's avatar

php artisan migrate:refresh error

QLSTATE[42S01]: Base table or view already exists: 1050 Table 'admin_settings' already exists

I delete the admin_settings table and run php artisan migrate its show error too

 Base table or view not found: 1146 Table
0 likes
17 replies
tisuchi's avatar

@siewlon6093 There are two ways to fix that.

  1. Delete all tables and run php artisan migrate

  2. Delete admin_settings related row from the migrations table and run php artisan migrate:refresh.

Hope it will work.

Spiral's avatar

@tisuchi yes first delete all tables

composer dump-autoload
php artisan migrate
siewlon6093's avatar

yes I have done all the step @tisuchi

 Base table or view not found: 1146 Table '
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class AdminSettings extends Model {

	protected $guarded = array();
	public $timestamps = false;

}

This is my models

tisuchi's avatar

@siewlon6093 What do you mean by done all the step?

I simply prefer if you don't have any important data in your tables, then delete all the tables from your database.

Then just run php artisan migrate command.

If you have still issue, don't forget to run the following commands that @siewlon6093 suggested...

composer dump-autoload
php artisan migrate
siewlon6093's avatar

yes @tisuchi I already delete all the tables in database and run php artisan migrate

 SQLSTATE[42S02]: Base table or view not found: 1146 Table 'euzlarmy_21pixar.admin_settings' doesn't exist (SQL: select * from `admin_settings` limit 1)

composer dump-autoload

Illuminate\Database\QueryException  : SQLSTATE[42S02]: Base table or view not found: 1146 Table 'euzlarmy_21pixar.admin_settings' doesn't exist (SQL: select * from `admin_settings` limit 1)

tisuchi's avatar

@siewlon6093 it seems the cache issue.

You can run php artisan and composer to get the available list of commands.

However, I can suggest running these following commands to remove cache-

composer clearcache
php artisan cache:clear
siewlon6093's avatar

OMG @tisuchi annoying error :(

When I run composer clear-cache, It clear all the cache

but when I run php artisan cache:clear go back to same errors

1 like
untymage's avatar

If you dont have sensitive data on your database run:

php artisan migrate:fresh
shez1983's avatar

can you post the code to admin_settings migrations, and a screen shot of all your migrations, i dont see why its trying to do select statement?

also if this is in your local server, then create a fresh database in sql, and change your .env to point to that and run php artisan migrate just to be sure

siewlon6093's avatar

php artisan migrate:fresh @untymage

Base table or view not found: 1146 Table 'euzlarmy_21pixar.admin_settings' doesn't exist (SQL: select * from `admin_settings` limit 1)
siewlon6093's avatar

@shez1983

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAdminSettingsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 *
     * @return void
	 */
	public function up()
	{
		Schema::create('admin_settings', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('title');
			$table->text('description');
			$table->string('welcome_text', 200);
			$table->text('welcome_subtitle');
			$table->string('keywords');
			$table->integer('result_request')->unsigned()->comment('The max number of images per request');
			$table->integer('limit_upload_user')->unsigned();
			$table->enum('status_page', array('0','1'))->default('1')->comment('0 Offline, 1 Online');
			$table->integer('message_length')->unsigned();
			$table->integer('comment_length')->unsigned();
			$table->enum('registration_active', array('0','1'))->default('1')->comment('0 No, 1 Yes');
			$table->enum('email_verification', array('0','1'))->comment('0 Off, 1 On');
			$table->string('email_no_reply', 200);
			$table->string('email_admin', 200);
			$table->enum('captcha', array('on','off'))->default('on');
			$table->integer('file_size_allowed')->unsigned()->comment('Size in Bytes');
			$table->enum('facebook_login', array('on','off'))->default('off');
			$table->text('google_analytics');
			$table->enum('invitations_by_email', array('on','off'))->default('on');
			$table->string('twitter', 200);
			$table->string('facebook', 200);
			$table->string('googleplus', 200);
			$table->string('linkedin', 200);
			$table->string('instagram', 200);
			$table->text('google_adsense');
			$table->enum('auto_approve_images', array('on','off'))->default('off');
			$table->integer('tags_limit')->unsigned();
			$table->enum('downloads', array('all','users'))->default('all');
			$table->enum('google_ads_index', array('on','off'))->default('off');
			$table->integer('description_length')->unsigned();
			$table->string('min_width_height_image', 25);
			$table->text('google_adsense_index');
			$table->string('link_privacy', 200);
			$table->string('link_terms', 200);
			$table->enum('twitter_login', array('on','off'))->default('off');
			$table->enum('paypal_sandbox', array('true','false'))->default('true');
			$table->string('paypal_account', 200);
			$table->integer('fee_commission')->unsigned();
			$table->string('stripe_secret_key', 200);
			$table->string('stripe_public_key', 200);
			$table->integer('max_deposits_amount')->unsigned();
			$table->integer('min_deposits_amount')->unsigned();
			$table->integer('min_sale_amount')->unsigned();
			$table->integer('max_sale_amount')->unsigned();
			$table->enum('enable_paypal', array('0','1'))->default('0');
			$table->enum('enable_stripe', array('0','1'))->default('0');
			$table->enum('currency_position', array('left','right'))->default('left');
			$table->string('currency_symbol', 200);
			$table->string('currency_code', 200);
			$table->integer('amount_min_withdrawal')->unsigned();
			$table->enum('sell_option', array('on','off'))->default('on');
			$table->enum('show_images_index', array('latest','featured','both'))->default('latest');
			$table->enum('show_watermark', array('1','0'))->default('1');
			$table->integer('file_size_allowed_vector')->unsigned()->default(1024);
		});
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('admin_settings');
	}

}

https://imgur.com/a/2naH92c

Please or to participate in this conversation.