|
|
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. |
|
cluster1 · 采取独立的新行动的好处是什么? 1 年前 |
|
|
Robert · 使用JSON或哈希时,将NULL替换为NIL 1 年前 |
|
|
Fred Willmore · Rails控制器不呈现任何模板 2 年前 |
|
|
Diogo Amaral · 实现API请求的正确方式 2 年前 |
|
|
Meknassih · 在控制器方法中分配给模型没有任何作用 2 年前 |
|
|
Michael Ding · Rails上的默认会话到期问题 2 年前 |
|
|
Flávio · 基于另外两个生成数组 2 年前 |