SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel8.projects' doesn't exist
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel8.projects' doesn't exist
In this session, we are going to try to solve the "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel8.projects' doesn't exist" puzzle by using the computer language.
-
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel8.projects' doesn't exist while using migration command
--PATH database\migrations\<yourmigrationfile>.phppublic function up() { //Schema::table('projects', function (Blueprint $table) { Schema::create('projects', function (Blueprint $table) { $table->id(); $table->string('name'); $table->timestamps(); }); }
SQLSTATE[42S02]: Base table or view not found: 1146 Table is the most common error while migrating the table in laravel. Update your migration file instead of
Schema::table('projects', function (Blueprint $table)
useSchema::create('projects', function (Blueprint $table)
in your migration file. There could be any reason for this error but in my case we got the solution usingcreate()
method instead oftable()
method.The table method on the Schema facade may be used to update existing table structure. But create method is used to create the new table structure which is not already exist. The
Schema::table
method is used to modify an existing table, useSchema::create
to create new one.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Generate random string lowercase in Laravel
- Laravel csrf token mismatch for ajax POST Request
- How to check records exist in loaded relationship in Laravel blade view
- Laravel 11 step by step instructions to upload file in storage directory and display in blade file
- How to avoid duplicate entries in pivot table in Laravel
- Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given
- External link not working in laravel blade
- If condition in foreach loop in laravel
- Get last record from table in laravel
- Composer\Exception\NoSslException
- Automatically remove records using Prunable trait in Laravel
- Laravel append URI in route
- Permanently delete a record in laravel
- Pagination in laravel
- How to set column as primary key in Laravel model
- How to check email is valid or not in Laravel
- Create project factory and seed data in laravel
- Class 'App\Providers\Auth' not found
- How to run a specific seeder class in laravel
- How to check duplicate entry in laravel
- How to validate website url in laravel using validaiton
- Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0"
- Array to string conversion laravel Controller
- There are no commands defined in the "route:" namespace
- How to get all posts which contains comments in laravel