Rails 通过迁移删除旧模型 [英] Rails remove old models with migrations

查看:23
本文介绍了Rails 通过迁移删除旧模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆 Rails 模型,我将它们重写为一个模型,以简化我的代码并减少不必要的表.

I have a bunch of rails models that i'm re-writing into a single model to simplify my code and reduce unnecessary tables.

我想知道删除模型类及其表的最佳方法是什么.我希望过去的迁移仍然成功,但我不想留下空模型.我是否必须手动删除引用这些模型的旧迁移,然后手动删除类文件?

I'm wondering what the best way to delete a model class and its table is. I want past migrations to still succeed, but I don't want to leave the empty models lying around. Do I have to manually delete the old migrations that reference these models, then manually delete the class files?

有没有人有任何提示可以做到这一点的最佳方法?

Does anyone have any tips for the best way to do this?

推荐答案

ruby script/destroy model怎么样?这应该照顾模型和迁移.

What about doing ruby script/destroy model? That should take care of the model and the migration.

这篇关于Rails 通过迁移删除旧模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆