Laravel 数据表迁移

使用 Artisan 命令 make:migration 就可以创建一个新的迁移:

php artisan make:migration create_users_table

新的迁移位于 database/migrations 目录下,每个迁移文件名都包含时间戳从而允许 Laravel 判断其顺序。

--table 和 --create 选项可以用于指定表名以及该迁移是否要创建一个新的数据表。这些选项只需要简单放在上述迁移命令后面并指定表名:

php artisan make:migration create_users_table --create=users   //直接创建users表
php artisan make:migration add_votes_to_users_table --table=users    //users表存在,向里面添加字段

更多信息参考:https://laravelacademy.org/post/8179.html/

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注