![]() |
1
6
不要担心时间戳。它将自动生成。 你可以做
This would automatically create a migration file which would look like this:
该文件将具有格式的时间戳。
|
![]() |
2
2
这个 Guide has information about generating migrations. If you use the rails generator, it will create correctly named files:
|
![]() |
3
1
Well you can do two things: 1) If you haven't deployed this anywhere yet, or you don't mind dumping the db and running your migrations again, then modify the file. 从数据库中删除表,然后运行db:migrate。Easy to do this in development. 2)如果此应用程序正在生产,或者您不想删除所有表。然后创建一个新的迁移文件。然后在这个新的迁移中添加/修改/删除列。然后运行db:migrate,新的更改将在表中生效。这是最佳实践。 至于命名迁移,使用时间戳是因为Rails将创建一个跟踪最近运行的迁移的表。为此,最好使用时间戳。但是如果您选择,您可以使用自己的约定而不是时间戳。Maybe name them 001_migration.rb, 002_migration.rb, etc. Hope that helps. |
![]() |
Stilian · 存储库设置中没有Github页面部分 3 年前 |
![]() |
Kellen · 查看$卷展栏功能列表 3 年前 |
![]() |
Akshit Thakur Ak · 我怎样才能把铁轨停下来? 3 年前 |
![]() |
johncssjs · 将数组转换为每个元素的嵌套哈希 3 年前 |
![]() |
solidsnake99 · Rails db:如何绕过验证 3 年前 |