更新时间:2023-12-01 09:34:52
是的,每次您需要以某种方式更改表时,都需要为其创建新的迁移.这就是迁移的重点.当您在协作环境中进行开发并从远程存储库中进行一些更改时,您应该做的一件事情(如果使用数据库)是运行其他开发人员可能创建的所有迁移.这样可以使您的数据库保持同步.
Yes, each time you need to change a table in some way you'd create a new migration for it. That's the whole point of migrations. When you're developing in a collaborative environment and you pull down some changes from a remote repository, one of the things you should do (if working with a database) is run any migrations that other developers might have created. This keeps your databases in sync.
当然可以偶尔删除并添加列,但这没什么大不了的.
Sure you might drop and add columns occasionally but it's no big deal.
首次创建表时,可能使用的是Schema::create()
.该表的所有后续迁移都应使用Scheme::table()
.它接受相同的参数,只是不先尝试创建表.
When you create a table for the first time you are probably using Schema::create()
. All subsequent migrations for that table should use Scheme::table()
. It accepts the same parameters except it doesn't attempt to create the table first.