Forum: Ruby on Rails Dealing with not-so-nice legacy schema...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3a524f1d890c88e1f46160d3f191b0a5?d=identicon&s=25 Ojis (Guest)
on 2009-02-05 20:02
(Received via mailing list)
Hello Gurus!

I have a problem with legacy database-schema and I would like to get
some ideas and suggestions how to handle it with ActiveRecord. First
the idea with database is that there can be several versions of the
same data. Current data is only one row but the same data can be saved
on several rows.

Example:
identification    varchar2(10)
area        varchar2(30)
owner      varchar2(50)
effective_date    datetime
termination_date  datetime

The SQL used to get current data is:
select * from example_table e where e.identification='123456' and
termination_date is null and effective_date=(select max
(effective_data) from example_data where identification='123456')

What I would like to achieve is at least partially RESTful wrapper
around the datamodel. There are dozens of tables like the example and
there aren't any integrity constraints defined (no foreign keys used).
Responsibility of the data-integrity is pushed to the application
logic.

Yes, if it were up to me the legacy schema would be modified and made
more sensible. Unfortunately I cannot affect since my application
isn't the only one using it. So I'm stuck with situation where I just
have to live with it.

I probably build couple of prototypes for managers with Sinatra before
making a full-blown rails-app. What would be the best way to wrap this
kind of datamodel under ActiveRecord-umbrella? Loads of custom SQL at
least I think.
3131fcea0a711e5ad89c8d49cc9253b4?d=identicon&s=25 Julian Leviston (Guest)
on 2009-02-06 04:16
(Received via mailing list)
Sounds fine to me. What's the problem?

Blog: http://random8.zenunit.com/
Learn rails: http://sensei.zenunit.com/
This topic is locked and can not be replied to.