I am trying to migrate the table but it throws an error saying the table name is not valid, Idk why, I check my database there is not even any similar name table, I follow the tutorial and this is working for video guy and not for me. Is there any way to fix it? I'm using laravel version 9
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug');
$table->longText('description');
$table->tinyInteger('status')->default('0');
$table->tinyInteger('popular')->default('0');
$table->string('.meta_title');
$table->string('.meta_description');
$table->string('.meta_keyword');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('categories');
}
};
Error
php artisan migrate
INFO Running migrations.
2022_12_04_110615_create_categories_table ............................................................................................... 5ms FAIL
Illuminate\Database\QueryException
SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table `categories` (`id` bigint unsigned not null auto_increment primary key, `name` varchar(191) not null, `slug` varchar(191) not null, `description` longtext not null, `status` tinyint not null default
'0', `popular` tinyint not null default '0', ``.`meta_title` varchar(191) not null, ``.`meta_description` varchar(191) not null, ``.`meta_keyword` varchar(191) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
CodePudding user response:
because there is a dot
before these columns
$table->string('.meta_title');
$table->string('.meta_description');
$table->string('.meta_keyword');
the compiler will expect the table name before the dot, when there is nothing before the dot it will throw this exception