如何在Rails应用程序中禁用迁移功能? [英] How do I disable the migrations feature in a Rails app?

查看:209
本文介绍了如何在Rails应用程序中禁用迁移功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我们分别设计数据库模型和应用模型(RDMBS架构师与OOP工程师)。从我看到的关于Rails和域/关键正常形式的信息,Rails迁移不能轻易地复制精心设计的企业RDBMS的所有功能(如果有的话),所以我们不迁移,而是使用其他工具来构建数据库不顾对象关系阻抗失配的问题)。数据完整性和数据库性能对于我们来说太贵了,无法为任何开发人员提供RDBMS模型更改。

We engineer database models and application models separately (RDMBS architects vs OOP engineers). From what I've seen regarding Rails versus domain/key normal form, Rails migrations cannot easily duplicate all the features of a well-designed enterprise RDBMS (if at all) so we don't migrate and instead use other tools to build databases (nevermind the problem of object-relational impedance mismatch). Data integrity and DB performance are too valuable to us to risk RDBMS model changes by any developer.

问题

由于任何原因,我们现在有一个Rails应用程序通过迁移对DB进行了更改。如何在现有的Rails应用程序中彻底禁用此功能?

For whatever reason, we now have a Rails app that has made damaging DB changes through migrations. How do I cleanly disable this feature in an existing Rails application?

我有我的理论,但我想知道世界的想法。

I have my theories but I want to know what the world thinks.

推荐答案

当测试终于来到前面时,再次出现。因此,我深入了解,并提出以下感谢,部分原因是对问题留下的意见。这将删除所有rake DB功能,测试仍然运行正常。 (如果有人想知道,当我们需要刷新它时,我们从其他地方复制测试数据库。)

This came up again when testing finally came to the front. Thus, I took deeper look and came up with the following thanks, in part, to the comments left on the question. This removes all rake DB capabilities and tests still run fine. (In case anyone is wondering, we clone the test DB from elsewhere when we need to refresh it.)

将其添加到 Rakefile

Add this to the Rakefile:

# Disable DB migrations, DB test preparing, etc.
Rake::Task.tasks.each do |t|
    if t.name[0,3] == "db:"
        t.clear
        t.add_description("!!! Disabled in favor of enterprise design at Acme.")
    end
end

注释掉所有的 test / test_helper.rb

#fixtures :all

这篇关于如何在Rails应用程序中禁用迁移功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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