【发布时间】:2014-07-13 21:01:46
【问题描述】:
我正在尝试在 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 key) default character set utf8 collate utf8_unicode_ci)
奇怪的是,如果我将表名从“categories”更改为“categoriez”,迁移就会成功运行。
这是我用来创建迁移的命令:
php artisan migrate:make create_categories_table --table=categories --create=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');
}
}
同样,如果我运行此迁移,我会收到错误消息,但如果我只是将“类别”更改为“类别”,则迁移会成功运行。
我之前设置了一个类别表,但我没有通过迁移设置该表。我已经放下了这张桌子。我还有一个已删除的类别模型文件。我已删除所有数据库表并重新运行所有迁移并尝试运行composer dump-autoload(尽管我不确定这与此问题有什么关系)。
为什么我在尝试创建类别表时会收到此“未找到表”错误?
我已经检查了这个与我的问题类似但没有帮助我解决这个错误的线程:Laravel 4 migrate base table not found
【问题讨论】: