我正在学习Laravel,并且有一个创建USERS表的工作迁移文件.作为迁移的一部分,我正在try 填充用户记录:
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填充数据.
有人知道怎么做吗?谢谢