rake db:migrate 手动为一个文件提供迁移

发布于 2025-01-08 21:48:37 字数 274 浏览 4 评论 0原文

不知何故,我的测试环境忘记复制多个迁移。为了排除故障,我想手动调用某些迁移文件。

是否有 rake db:migrate 选项或技巧允许我传递一个充满应该运行的迁移的目录?或者甚至是要运行的特定迁移文件?

这些迁移不存在于 db/migrate/ 下,而是存在于另一个 gems 的迁移文件夹中 (/home/ber/.rvm/gems/ruby-1.8.7-p302@xxx/ gems/spree_auth-1.0.0/db/migrate/)。

Somehow my test environment forgot to copy over several migrations. In order to troubleshoot, I want to call certain migration files by hand.

Is there a rake db:migrate option or trick that allows me to pass in a directory full of migrations that should be ran? Or even a specific migration file that will be ran?

These migrations are not present under db/migrate/, but rather in another gems' migration folder (/home/ber/.rvm/gems/ruby-1.8.7-p302@xxx/gems/spree_auth-1.0.0/db/migrate/).

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

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

发布评论

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

评论(2

你不是我要的菜∠ 2025-01-15 21:48:37

如果您使用特定版本生成迁移,则这篇文章将帮助您。

来自帖子:

rake db:migrate:up VERSION=20090408054532

其中 VERSION= 设置为您这一代的任何内容。

If you generate your migrations with a specific version then this post will help you with that.

From post:

rake db:migrate:up VERSION=20090408054532

Where VERSION= is set to whatever comes from your generation.

美人迟暮 2025-01-15 21:48:37

尝试运行此命令,

rake db:migrate:status

您会发现一个包含所有迁移的表,

选择您想要迁移或取消迁移的版本
然后

rake db:migrate VERSION=201853073732  

请注意,如果您陷入迁移过程中,这将不起作用,如果您必须注释掉已迁移的行
祝你好运

try running this

rake db:migrate:status

you will find a table with all your migrations

choose the version you would like to migrate or unmigrate
then

rake db:migrate VERSION=201853073732  

Notice that this won't work if you are stuck in mid migrations if you are you have to comment out the lines that were already migrated
Good luck

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