迁移格式 Add x to y 中是否存在(必要的)冗余?
要将电话列添加到门票表中,我可以这样写:
ruby script/generate migration AddPhoneToTickets phone:string
这里似乎有冗余。 但有必要吗?
我们不是在重复自己吗,要求在迁移名称 (AddPhoneToTickets
) 和列定义 (phone:string
) 中指定“phone” ?
To add the phone column to the tickets table, I can write:
ruby script/generate migration AddPhoneToTickets phone:string
There seems to be a redundancy here. But is it necessary?
Aren't we repeating ourselves by being required to specify "phone" both in the name of the migration (AddPhoneToTickets
) as well as in the column definition (phone:string
)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要将“电话”放入迁移名称中。 例如,如果您要添加一堆联系人字段,您可以轻松地调用它
AddContactFieldsToTickets
并指定所有字段。 实际上,除了表名称之外,使用迁移名称还不够具体。You're not required to put Phone in the migration name. For example, if you were adding a bunch of contact fields, you could just as easily call it
AddContactFieldsToTickets
and specify all the fields. It's not specific enough to use the name of the migration for anything but the table name, really.