生成迁移文件

每次需要更改架构时,使用正确的文件名创建新的迁移文件将是一件苦差事。值得庆幸的是,Laravel 的 artisan 命令可以为你生成迁移:

php artisan make:migration add_last_logged_in_to_users_table

你也可以使用上面的命令使用 --table--create 标志。这些是可选的,只是为了方便起见,并将相关的样板代码插入到迁移文件中。

php artisan make:migration add_last_logged_in_to_users_table --table=users

php artisan make:migration create_logs_table --create=logs

你可以使用 --path 选项为生成的迁移指定自定义输出路径。该路径相对于应用程序的基本路径。

php artisan make:migration --path=app/Modules/User/Migrations