Message from discussion
Support for views on activerecord
Received: by 10.236.178.3 with SMTP id e3mr47083983yhm.3.1342090000405;
Thu, 12 Jul 2012 03:46:40 -0700 (PDT)
X-BeenThere: rubyonrails-core@googlegroups.com
Received: by 10.236.114.20 with SMTP id b20ls2935502yhh.2.gmail; Thu, 12 Jul
2012 03:46:33 -0700 (PDT)
Received: by 10.236.191.40 with SMTP id f28mr104895083yhn.2.1342089993747;
Thu, 12 Jul 2012 03:46:33 -0700 (PDT)
Received: by 10.236.191.40 with SMTP id f28mr104895081yhn.2.1342089993720;
Thu, 12 Jul 2012 03:46:33 -0700 (PDT)
Return-Path: <dutta.a...@googlemail.com>
Received: from mail-yw0-f45.google.com (mail-yw0-f45.google.com [209.85.213.45])
by gmr-mx.google.com with ESMTPS id h70si420490yhk.2.2012.07.12.03.46.33
(version=TLSv1/SSLv3 cipher=OTHER);
Thu, 12 Jul 2012 03:46:33 -0700 (PDT)
Received-SPF: pass (google.com: domain of dutta.a...@googlemail.com designates 209.85.213.45 as permitted sender) client-ip=209.85.213.45;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dutta.a...@googlemail.com designates 209.85.213.45 as permitted sender) smtp.mail=dutta.a...@googlemail.com; dkim=pass header...@googlemail.com
Received: by mail-yw0-f45.google.com with SMTP id p34so425957yhp.18
for <rubyonrails-core@googlegroups.com>; Thu, 12 Jul 2012 03:46:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=googlemail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to
:content-type;
bh=lhOGCnKzutokNIXSy5qG0M9jARlryw9i/bc2fV+kons=;
b=oNj8vjgkyX5zpPEcBFImEhZfbpMFwzK7wWgktg0Uei46+mndCF0qgYGGKqE/f40RUb
MTPfHxqQeH2GuAn9RHBnjO0sKBl0EuUBD2PDMANK/d6/w59l2BSyliabt27yWHay1NQq
RwAjl9n+PconW9iAx5t+MPPJSEoLj7q4Uro2VAIonkNq9nLV6ZNA+Eh5EyAJIclwiYD+
ldZ0ly/mWpgtz9VehwzDl5KnW3Hvzt/vnbJRr6Vn5hf7DzKA2cbnwhiS9oB8o+BcEruA
rD4AB6KD4NhtRq9y+m+rIe1FlxnZ/4VX7yUcpsn3mbShLKQi/wtmG5ic8obLboA+zMFu
9/WQ==
Received: by 10.236.72.70 with SMTP id s46mr17999738yhd.108.1342089993460;
Thu, 12 Jul 2012 03:46:33 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.236.114.138 with HTTP; Thu, 12 Jul 2012 03:46:13 -0700 (PDT)
In-Reply-To: <CA+Xr2fAnPpZYde+XGotAWuqn_VvNGtZmFRnTQhw2QtUP3TY...@mail.gmail.com>
References: <EDBEF773-65EC-4769-9EEF-9BB189278...@gmail.com>
<CAEUKiYGRso+DAdSsDuEyXyckHOcdEt46k6w5gNhRiNb1gEP...@mail.gmail.com>
<CAG_VBhMM2V_1j4-XtoGahV5HLzMLicGUxcmM6A6YDbz-Jnm...@mail.gmail.com>
<1DE8249F28AF472CB0B1DB3A4007E...@gmail.com> <4FFE016D.6060...@jonathanleighton.com>
<DDEC273D-0196-4D23-9C7D-984715A5F...@metaskills.net> <CA+Xr2fAnPpZYde+XGotAWuqn_VvNGtZmFRnTQhw2QtUP3TY...@mail.gmail.com>
From: Anuj Dutta <dutta.a...@googlemail.com>
Date: Thu, 12 Jul 2012 11:46:13 +0100
Message-ID: <CAFbLOGCSRMLhsJu2eGUTuWPuKkVeFHyE6yKJuWy-zLRDVqa...@mail.gmail.com>
Subject: Re: [Rails-core] Support for views on activerecord
To: rubyonrails-core@googlegroups.com
Content-Type: multipart/alternative; boundary=20cf300514be511c2e04c49fad54
--20cf300514be511c2e04c49fad54
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
I have been using schema_format =3D :sql for adding postgres extensions and
haven't had any issues with it.
Anuj
On 12 July 2012 07:38, Damien Mathieu <4...@dmathieu.com> wrote:
> In 3.2 and above, you can use schema_format =3D :sql to generate a
> structure.sql file instead of the schema.rb.
>
> https://github.com/rails/rails/commit/43821bf3513c27913a4d861c83e11b0ad62=
99916
>
> I'm finding using this all the time, as it keeps my views from the
> migrations, and it also allows me to activate postgres extensions directl=
y
> from the migration.
>
> Damien MATHIEU | Ing=E9nieur logiciel
> 84, rue Chevreul | 69 007 Lyon
> Tel. : +33 (0)6 88 42 00 15 | http://dmathieu.com
>
>
>
> On 12 July 2012 01:34, Ken Collins <k...@metaskills.net> wrote:
>
>>
>> John,
>>
>> Perhaps make a few directories like db/procedures, db/views, etc and jus=
t
>> create a rake task in the db namespace that overrides or extends those i=
n
>> ActiveRecord's databases.rake? I've had to do this often with legacy
>> databases in many forms. This github project talks about it for those
>> coming from legacy DBs in SQL Server.
>>
>> https://github.com/rails-sqlserver/AdventureWorks.Ruby#test-database-tas=
ks
>>
>> In some cases, I use a little rake extension called #alias_task when
>> needing to override a particular task.
>>
>>
>> http://metaskills.net/2010/05/26/the-alias_method_chain-of-rake-override=
-rake-task/
>>
>> In your case, since you want to stick with schema.rb, you could perhaps
>> #alias_task on the db:schema:load task, then invoke it, then load up you=
r
>> procedures, views etc from the nested db directories? I would be open to
>> hearing how others do this too, but I have always found working with
>> special schemas and DDL's quite easy with ActiveRecord when you know the
>> pressure points.
>>
>>
>> - Ken
>>
>>
>> On Jul 11, 2012, at 6:42 PM, Jon Leighton wrote:
>>
>> > One thing that I have recently found myself desiring is the ability to
>> augment schema.rb with snippets of SQL.
>> >
>> > For example, I use Postgres, and need to declare some case-insensitive
>> indexes. This is not currently possible using Rails directly.
>> >
>> > I don't want to switch to use the SQL schema dump format, because
>> that's highly dependent on the database version. E.g. I am using Postgre=
s
>> 9, and another developer is using 8.4. We will probably end up overwriti=
ng
>> each other's schema.sql files if we went this route.
>> >
>> > But it would be nice to have, say, a db/schema_extra.sql where we coul=
d
>> manually place additional stuff like our case-insensitive indexes or
>> whatever.
>> >
>> > Or views...
>> >
>> > --
>> > http://jonathanleighton.com/
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Ruby on Rails: Core" group.
>> > To post to this group, send email to rubyonrails-core@googlegroups.com=
.
>> > To unsubscribe from this group, send email to
>> rubyonrails-core+unsubscribe@googlegroups.com.
>> > For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-core?hl=3Den.
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "Ruby on Rails: Core" group.
>> To post to this group, send email to rubyonrails-core@googlegroups.com.
>> To unsubscribe from this group, send email to
>> rubyonrails-core+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-core?hl=3Den.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-core+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-core?hl=3Den.
>
--=20
Anuj DUTTA
--20cf300514be511c2e04c49fad54
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
I have been using=A0schema_format =3D :sql=A0for adding postgres extensions=
and haven't had any issues with it.<div><br></div><div>Anuj</div><div>=
<br><br><div class=3D"gmail_quote">On 12 July 2012 07:38, Damien Mathieu <s=
pan dir=3D"ltr"><<a href=3D"mailto:4...@dmathieu.com" target=3D"_blank">42=
@dmathieu.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">In 3.2 and above, you can use schema_format =
=3D :sql to generate a structure.sql file instead of the schema.rb.<div><a =
href=3D"https://github.com/rails/rails/commit/43821bf3513c27913a4d861c83e11=
b0ad6299916" target=3D"_blank">https://github.com/rails/rails/commit/43821b=
f3513c27913a4d861c83e11b0ad6299916</a></div>
<div><br></div><div>I'm finding using this all the time, as it keeps my=
views from the migrations, and it also allows me to activate postgres exte=
nsions directly from the migration.</div><div><span class=3D"HOEnZb"><font =
color=3D"#888888"><br clear=3D"all">
<div style=3D"background-color:transparent">
<span style=3D"font-family:Times;font-size:medium"><div style=3D"background=
-color:transparent"><span style=3D"vertical-align:baseline;font-variant:nor=
mal;color:rgb(51,51,51);font-style:normal;font-size:8pt;white-space:pre-wra=
p;text-decoration:none;font-family:Verdana;font-weight:bold">Damien MATHIEU=
| Ing=E9nieur logiciel</span><br>
<span style=3D"vertical-align:baseline;font-variant:normal;color:rgb(51,51,=
51);font-style:normal;font-size:8pt;white-space:pre-wrap;text-decoration:no=
ne;font-family:Verdana;font-weight:bold">84, rue Chevreul | 69 007 Lyon</sp=
an><br>
<span style=3D"vertical-align:baseline;font-variant:normal;color:rgb(51,51,=
51);font-style:normal;font-size:8pt;white-space:pre-wrap;text-decoration:no=
ne;font-family:Verdana;font-weight:bold">Tel. : =A0<a href=3D"tel:%2B33%20%=
280%296%2088%2042%2000%2015" value=3D"+33688420015" target=3D"_blank">+33 (=
0)6 88 42 00 15</a> |</span><span style=3D"vertical-align:baseline;font-var=
iant:normal;font-style:normal;font-size:8pt;white-space:pre-wrap;text-decor=
ation:none;font-family:Verdana;font-weight:bold"> </span><a href=3D"http://=
dmathieu.com/" target=3D"_blank"><span style=3D"vertical-align:baseline;fon=
t-variant:normal;color:rgb(0,0,153);font-style:normal;font-size:8pt;white-s=
pace:pre-wrap;text-decoration:underline;font-family:Verdana;font-weight:bol=
d">http://dmathieu.com</span></a></div>
</span></div></font></span><div><div class=3D"h5"><br>
<br><br><div class=3D"gmail_quote">On 12 July 2012 01:34, Ken Collins <span=
dir=3D"ltr"><<a href=3D"mailto:k...@metaskills.net" target=3D"_blank">ke=
n...@metaskills.net</a>></span> wrote:<br><blockquote class=3D"gmail_quote"=
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
John,<br>
<br>
Perhaps make a few directories like db/procedures, db/views, etc and just c=
reate a rake task in the db namespace that overrides or extends those in Ac=
tiveRecord's databases.rake? I've had to do this often with legacy =
databases in many forms. This github project talks about it for those comin=
g from legacy DBs in SQL Server.<br>
<br>
<a href=3D"https://github.com/rails-sqlserver/AdventureWorks.Ruby#test-data=
base-tasks" target=3D"_blank">https://github.com/rails-sqlserver/AdventureW=
orks.Ruby#test-database-tasks</a><br>
<br>
In some cases, I use a little rake extension called #alias_task when needin=
g to override a particular task.<br>
<br>
<a href=3D"http://metaskills.net/2010/05/26/the-alias_method_chain-of-rake-=
override-rake-task/" target=3D"_blank">http://metaskills.net/2010/05/26/the=
-alias_method_chain-of-rake-override-rake-task/</a><br>
<br>
In your case, since you want to stick with schema.rb, you could perhaps #al=
ias_task on the db:schema:load task, then invoke it, then load up your proc=
edures, views etc from the nested db directories? I would be open to hearin=
g how others do this too, but I have always found working with special sche=
mas and DDL's quite easy with ActiveRecord when you know the pressure p=
oints.<br>
<span><font color=3D"#888888"><br>
<br>
=A0- Ken<br>
</font></span><div><div><br>
<br>
On Jul 11, 2012, at 6:42 PM, Jon Leighton wrote:<br>
<br>
> One thing that I have recently found myself desiring is the ability to=
augment schema.rb with snippets of SQL.<br>
><br>
> For example, I use Postgres, and need to declare some case-insensitive=
indexes. This is not currently possible using Rails directly.<br>
><br>
> I don't want to switch to use the SQL schema dump format, because =
that's highly dependent on the database version. E.g. I am using Postgr=
es 9, and another developer is using 8.4. We will probably end up overwriti=
ng each other's schema.sql files if we went this route.<br>
><br>
> But it would be nice to have, say, a db/schema_extra.sql where we coul=
d manually place additional stuff like our case-insensitive indexes or what=
ever.<br>
><br>
> Or views...<br>
><br>
> --<br>
> <a href=3D"http://jonathanleighton.com/" target=3D"_blank">http://jona=
thanleighton.com/</a><br>
><br>
><br>
> --<br>
> You received this message because you are subscribed to the Google Gro=
ups "Ruby on Rails: Core" group.<br>
> To post to this group, send email to <a href=3D"mailto:rubyonrails-cor=
e@googlegroups.com" target=3D"_blank">rubyonrails-core@googlegroups.com</a>=
.<br>
> To unsubscribe from this group, send email to <a href=3D"mailto:rubyon=
rails-core%2Bunsubscribe@googlegroups.com" target=3D"_blank">rubyonrails-co=
re+unsubscribe@googlegroups.com</a>.<br>
> For more options, visit this group at <a href=3D"http://groups.google.=
com/group/rubyonrails-core?hl=3Den" target=3D"_blank">http://groups.google.=
com/group/rubyonrails-core?hl=3Den</a>.<br>
><br>
<br>
--<br>
You received this message because you are subscribed to the Google Groups &=
quot;Ruby on Rails: Core" group.<br>
To post to this group, send email to <a href=3D"mailto:rubyonrails-core@goo=
glegroups.com" target=3D"_blank">rubyonrails-core@googlegroups.com</a>.<br>
To unsubscribe from this group, send email to <a href=3D"mailto:rubyonrails=
-core%2Bunsubscribe@googlegroups.com" target=3D"_blank">rubyonrails-core+un=
subscribe@googlegroups.com</a>.<br>
For more options, visit this group at <a href=3D"http://groups.google.com/g=
roup/rubyonrails-core?hl=3Den" target=3D"_blank">http://groups.google.com/g=
roup/rubyonrails-core?hl=3Den</a>.<br>
<br>
</div></div></blockquote></div><br></div></div></div><div class=3D"HOEnZb">=
<div class=3D"h5">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;Ruby on Rails: Core" group.<br>
To post to this group, send email to <a href=3D"mailto:rubyonrails-core@goo=
glegroups.com" target=3D"_blank">rubyonrails-core@googlegroups.com</a>.<br>
To unsubscribe from this group, send email to <a href=3D"mailto:rubyonrails=
-core%2Bunsubscribe@googlegroups.com" target=3D"_blank">rubyonrails-core+un=
subscribe@googlegroups.com</a>.<br>
For more options, visit this group at <a href=3D"http://groups.google.com/g=
roup/rubyonrails-core?hl=3Den" target=3D"_blank">http://groups.google.com/g=
roup/rubyonrails-core?hl=3Den</a>.<br>
</div></div></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>=
Anuj DUTTA<br>
</div>
--20cf300514be511c2e04c49fad54--