生成用于丢弃迁移的轨道模型

发布于 2024-11-26 11:48:46 字数 423 浏览 0 评论 0原文

我有一个模型客户,是我使用以下代码生成的

rails g 模型客户名称:字符串

一段时间后,我决定将模型重命名为 customer_type,为了完成此任务,我们编写了另一个迁移

rails g 迁移RenameCutomerToCustomerType

一切都很顺利,直到我需要添加名为 customer 的模型。当我发出以下命令时,我开始收到“另一个迁移已命名为 create_customer”

rails g 模型客户

我认为这种情况在基于 CRUD 的项目中很常见,请建议如何解决这个问题?这是 Rails 的限制吗?

I had a model customer, which I have generated using the following

rails g model Customer name:string

After some time, I decided to rename the model to customer_type, to accomplish this we wrote an another migration

rails g migration RenameCutomerToCustomerType

everything was smooth until I had the requirement to add the model named customer. When I issued the following command, I've started getting "Another migration is already named create_customer"

rails g model Customer

I think this kind of scenario is very common in CRUD based project, please suggest on how to over come this? Is this a limitation with rails?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇俏 2024-12-03 11:48:46

只需重命名旧的迁移文件名和类名即可。两者都不影响什么。

顺便说一句:这种情况非常罕见,所以我认为框架不需要采取任何特定操作

Just rename old migration filename and classname. Both don't affect anything.

btw: This scenario is quite rare so I don't think that there is any need in specific actions from framework

叹梦 2024-12-03 11:48:46

Rails destroy model MODELNAME,将删除该模型。

rails destroy model MODELNAME, will remove the model.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文