Php 拉威尔,为什么能';我是否使用稍微不同的表名拼写成功地运行了create table迁移?
我正在尝试在Laravel 4中运行迁移,但不断出现以下错误:Php 拉威尔,为什么能';我是否使用稍微不同的表名拼写成功地运行了create table迁移?,php,laravel,laravel-4,Php,Laravel,Laravel 4,我正在尝试在Laravel 4中运行迁移,但不断出现以下错误: [Illuminate\Database\QueryException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ramen.categories ' doesn't exist (SQL: create table `categories` (`id` int unsigned not null auto_increment primary ke
[Illuminate\Database\QueryException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ramen.categories ' doesn't exist (SQL: create table `categories` (`id` int unsigned not null auto_increment primary key) default character set utf8 collate utf8_unicode_ci)
奇怪的是,如果我将表名从“categories”更改为“categoriez”,迁移就会成功运行
这是我用来创建迁移的命令:
php artisan migrate:make create_categories_table --table=categories --create=categories
这是实际的迁移文件:
}
同样,如果我运行这个迁移,我会得到错误,但是如果我简单地将“categories”更改为“categoriez”,迁移就会成功运行
我之前设置了一个categroies表,但我没有通过迁移设置它。我把这张桌子掉了。我还删除了一个类别模型文件。我已经删除了所有数据库表,重新运行了所有迁移,并尝试运行了composer dump autoload
(但我不确定这是否与此问题有关)
为什么我在尝试创建categories表时出现“table not found”错误
我已经检查了这个与我的问题类似的线程,但没有帮助我解决这个错误:事实证明这是MYSQL的问题,而不是Laravel的问题。我试图直接在PHP MyAdmin中创建一个“categories”表,但无法做到这一点 创建一个任意命名的表,将该表重命名为“categories”,然后删除该表,似乎可以解决这个问题。之后,我成功地运行了迁移
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCategoriesTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function(Blueprint $table)
{
$table->increments('id');
$table->timestamps();
$table->integer('parent')->unsigned();
$table->string('category_type');
$table->string('name');
$table->string('type');
$table->index('type');
$table->index('parent');
$table->index('name');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('categories');
}