我正在关注 Dayle Rees's tutorial on migrations in Laravel 4 . (请参阅链接以了解我的问题)。我正在尝试使用 Artisan 制作一些迁移文件。我在段落开头“我们只是运行...”,然后是示例 Artisan 命令:
php artisan migrate:make create_users --create --table=users
...接着是结果代码(片段):
public function up()
{
Schema::create('users', function(Blueprint $table)
{
$table->increments('id');
$table->timestamps();
});
}
但是当我运行相同的 artisan 命令时,我不明白。我得到了这个:
public function up()
{
Schema::table('users', function(Blueprint $table)
{
//
});
}
为什么?
也许这是 Laravel 版本比 Rees 先生在该教程中使用的版本稍晚的结果,但最烦人/令人困惑的是工匠命令
--create
似乎不能正常工作,即。它正在输出Schema::table()
代替
Schema::create()
最佳答案
好的,对于任何阅读本文的人,我已经找到了答案。我认为这可能是 Dayle Rees 的教程中的一个错误。关注 docs ,工匠命令应该是
php artisan migrate:make create_users_table --create=users
所以这个故事的寓意是,当迁移是为了创建一个表时,相关的命令应该是
php artisan migrate:make class_name --create=table_name
修改时,命令为
php artisan migrate:make class_name --table=table_name
关于laravel-4 - Artisan migrate:make --create 命令不会生成 Schema::create(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20732949/