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
- Target class [App\Http\Controllers\Auth\Request] does not exist.
- How to get file extension from input type file in laravel
- Update if exist else insert new record in laravel
- How to Run CRON Job on LIVE SERVER on Cpanel in Laravel Project
- Get current month records in laravel 7/8
- Array to string conversion laravel blade
- SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'posts_user_id_foreign'; check that column/key exists
- Pass value from controller to model in laravel
- How to get specific columns using Laravel eloquent methods
- How to upload files to amazon s3 bucket using Laravel
- Laravel onclick function not working
- How to get route name on visit URL in laravel
- Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0"
- How to display 1 day ago in comments in laravel view
- How to pass data to route in laravel?
- How to change default timestamp fields name in Laravel
- How to check data inserted or deleted in pivot after toggle method
- Route prefix with auth middleware in laravel
- Create user in Laravel using tinker
- Create record with unique slug in laravel
- How to insert ckeditor data into database in Laravel?
- Update email with unique validation in laravel
- InRandomOrder() method with example in laravel
- How to display a specific word from a string in laravel
- Docker important commands to run laravel application with docker