-2

I've been building a laravel application, then xampp gave so many issues so I deleted it with the databases. Then created new empty database and tried to migrate, but it giving me this error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'accept.users' doesn't exist (SQL: select * from users where id = 1 limit 1)

  at C:\Users\eymen\OneDrive\Desktop\work\websites\accept\vendor\laravel\framework\src\Illuminate\Database\Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

  i   A table was not found: You might have forgotten to run your database migrations.
      https://laravel.com/docs/master/migrations#running-migrations

  1   [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(App\Providers\RouteServiceProvider))

  2   C:\Users\eymen\OneDrive\Desktop\work\websites\accept\vendor\laravel\framework\src\Illuminate\Database\Connection.php:414
      PDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'accept.users' doesn't exist")

I've tried to re-install the project and after installed composer I tried to migrate and got the same error. I've also tried to create a temporary users table with only 1 column, but it gave me error asking about the other columns.

I literally have no idea what to do (even chatGPT freaked out).

1
  • 1
    it looks like you have a missing migration, or you created something without a migration... if you have the migrations, then check they are named correctly so they are executed in the correct order... Commented Feb 25, 2023 at 16:42

3 Answers 3

0

try running php artisan migrate:fresh in case it`s development DB

2
  • still getting the same error
    – yasir
    Commented Feb 26, 2023 at 11:07
  • then you should review all the migrations for some semantic errors, such as creating User record before table created
    – Kriso
    Commented Mar 2, 2023 at 4:39
0

the problem is that php artisan executes some codes in the website some why, and I have a User::all() in my code. the problem solved by commenting the web.php contents.

0

After creating the database, edit the .env file.

And run php artisan migrate:fresh

Or make sure to rename the migration files in correct order.

1
  • still getting the same error
    – yasir
    Commented Feb 26, 2023 at 11:07

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.