
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
- How to prevent host header attack in Laravel
- How to validate form input data in laravel
- Method Illuminate\Events\Dispatcher::fire does not exist
- How to check email is valid or not in Laravel
- How to create projects method with belongstomany relationship in user model
- Always load the relationship data with eager loading in Laravel
- How to add is_activated column in database using laravel migration
- Get only 10 records from table in laravel
- How to automatically update the timestamp of parent model in Laravel
- Undefined property: stdClass::$title
- How to validate URL with https using regex in laravel
- Create model with migration and seeder
- How to insert dynamic values to additional column with pivot column in pivot table on multiple records
- How to increment column value of table in Laravel
- Root composer.json requires php ^7.3 but your php version (8.0.0) does not satisfy that requirement
- Define variable and use in Laravel controller method
- Laravel create multiple records in Pivot table
- Command to create MySQL Docker image and access the MySQL command-line interface (CLI) within a running Docker container
- Laravel migration add foreign key to existing table
- Redirect to another view from controller in laravel
- Php artisan make model, factory, migration and controller in single command
- How to authenticate admin users in Laravel ?
- Redirect to previous page or url in laravel
- How to get list of all views file in laravel
- Laravel onclick function not working