我正在学习 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.example`,
'verified' => true
)
);
});
}
但是当我运行php artisan migrate
时,出现了以下错误:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'vantage.users' doesn't exist
这显然是因为Artisan还没有创建表格,但所有文档似乎都说可以使用Fluent Query作为迁移的一部分来填充数据。有人知道怎么做吗?