English 中文(简体)
如何从数据库中产生积极的记录模型
原标题:how to generate active record models from database

我正在寻找一种工具或方法,能够把我的庞大旧数据库转换成积极记录模型定义......如反向工程......。

问题回答

This is less a reverse engineering problem and more a "does your legacy database adhere to the active record conventions" problem. Most do not and from my experience, it s almost easier to do some migration work on the data end to get it in a state such that it does adhere to those conventions. Rails is a very opinionated piece of software, the less you argue with it, the happier you ll be.

我的两点......

索赖我也不了解一种工具。 但是,正如愤怒显示的那样,创建积极的记录模式确实很简单。 此外,你可能必须说明表格名称和主要钥匙:

class Artikelgruppe < ActiveRecord::Base
  set_table_name "tblArtGrp"
  set_primary_key "ArtGrpID"
end

由于我的铁路应用只使用我们遗留数据库的一小部分,我更希望对我在数据库中应用的需要形成具体的看法。 我确实有问题描述的是铁路的7个以上的模型,但是,在数据库中建立7个表格的想法确实容易。

Why do the Rails people still think they are the centrum of the universe? I have a dozen applications written in different languages and the common ground is the database. Imagine I would have to change the database to make Rails happy ...

RM似乎是此处所列两人的最佳选择。 你们在特别少见之后,要么能够把它放在你身上。 地图,离不开数据库的银汇,你想要扫描。 如果你在铁路下,或者在你看不出的底部里,就是这样。

一件事: 对于非铁路公司来说,它将产生一种[模块]-基准,形成一种单独的“积极记录:基础,并将把班子装入你选择的模块,并形成一种单独的“积极记录:每个班子”。

RMRE的模型产生的所有关系(归属-to, has_many, 等等)都自动地为你们服务。 对于非铁路来说,或者如果你在座标中具体指明,这些铁路将装入你的一个单元。

The rare_map gem also mentioned above only created empty models for me, which does not buy you a whole lot.

你们会积极这样做。 您实际上不必在自己的模式中具体说明一栏。 假设一个完整的<代码>用户表,就简单地将以下条目放在<代码> 应用程序/模型/用户上。

class User < ActiveRecord::Base

end

之后,可以补充你想要做的更多证明。

尽管如此,你可能不想这样做。 由于铁路“环形”座右铭,那些试图运输旧项目的人很困难。 如果你试图将铁路与你现有的数据库图谱连接起来,这将是一场激烈的战斗。

查阅RMRE gem。 http://pragdevnotes.com/201009/30/rmre-rails-models-reverse-engineering-gem” rel=“nofollow”>introducing blog post written by RMRE author.





相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签