【发布时间】:2012-09-26 00:17:00
【问题描述】:
我刚刚学习 Laravel,并且有一个工作迁移文件创建一个用户表。作为迁移的一部分,我正在尝试填充用户记录:
public function up()
{
Schema::create('users', function($table){
$table->increments('id');
$table->string('email', 255);
$table->string('password', 64);
$table->boolean('verified');
$table->string('token', 255);
$table->timestamps();
DB::table('users')->insert(
array(
'email' => 'name@domain.com',
'verified' => true
)
);
});
}
但是在运行php artisan migrate 时出现以下错误:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'vantage.users' doesn't exist
这显然是因为 Artisan 尚未创建表,但所有文档似乎都说有一种方法可以使用 Fluent Query 来填充数据作为迁移的一部分。
有人知道怎么做吗?谢谢!
【问题讨论】:
标签: php laravel migration mysql-error-1146