TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Rails_on_pg: PostgreSQL views, functions, triggers, FKs for rails migrations

31 点作者 spidaman超过 15 年前

4 条评论

jawngee超过 15 年前
Can anyone clue me in on how this is helpful (not slagging, just generally curious). Like I don't see how this:<p><pre><code> 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'=&#62;'active','p.name' =&#62; 'John' #or "p.status='active' and p.name='John'" end </code></pre> is easier than:<p><pre><code> 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'; </code></pre> 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.<p>Is it because you can't do straight SQL in rail's migration stuff?<p>Thanks.
评论 #889052 未加载
评论 #889207 未加载
100k超过 15 年前
I've been using sexy_pg_constraints with good success for a while. Doesn't do functions like this though.<p><a href="http://github.com/maxim/sexy_pg_constraints" rel="nofollow">http://github.com/maxim/sexy_pg_constraints</a><p>You do have to switch to sql export for the schema which is kind of a bummer because it's not supported as well by Rails as the "db independent" (aka lowest common denominator) schema.rb file.
MartinMond超过 15 年前
Anyone know if it keeps db/schema.rb in sync?
评论 #888566 未加载
alexyim超过 15 年前
I thought this was about Paul.