create_view :active_patients do |view|
view.select 'p.patient_id as id' ,'p.id as visit_id'
view.from 'patients as p'
view.join 'left join demographics d on d.visit_id=v.id'
view.conditions 'p.status'=>'active','p.name' => 'John' #or "p.status='active' and p.name='John'"
end
is easier than: create or replace view patient.active_patients as
select p.patient_id as id, p.id as visit_id
from patients p
left join demographics d on d.visit_id=v.id
where p.status='active' and p.name = 'John';
I don't use rails, and the ORM we use generates in reverse, so we define our database using SQL and then generate the model layer from that. We use a lot of views, stored procs and postgresql features such as table inheritance, which no ORM seems to handle going the forward route.Is it because you can't do straight SQL in rail's migration stuff?
Thanks.