
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 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(); }); }
0SQLSTATE[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.
Random Code Snippet Queries: Laravel
- How to customize pagination view in laravel
- Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0"
- Permanently delete a record in laravel
- Argument 1 passed to App\Http\Controllers\Auth\LoginController::authenticated() must be an instance of App\Http\Controllers\Auth\Request
- How to pass query string to url in laravel
- InRandomOrder() method with example in laravel
- How to create pivot table in laravel using migration
- How to get records in random order in laravel
- Update email with unique validation in laravel
- How to decrypt laravel password
- Return view from route Laravel
- Create model with migration and seeder
- How to get selected categories on edit record with Select2
- How to create and run user seeder in laravel
- Get comma separated email from input array
- Get all users except the followings users in overtrue laravel-follow
- Submit form without CSRF token in Laravel
- Root composer.json requires php ^7.3 but your php version (8.0.0) does not satisfy that requirement
- Database transactions in laravel
- Touch parent updated_at in Laravel
- How to get column names from table in Laravel
- Import/Use Storage facade in laravel
- Syntax error or access violation: 1072 Key column 'role_id' doesn't exist in table (SQL: alter table `users` add constraint `users_role_id_foreign` foreign key (`role_id`) references `roles` (`id`))
- Post model with title and body in laravel 8
- Pass variable from blade to controller Laravel