Creating a View(database) with Migration

Hi,

Is there a way to create a view using ruby migration? I could run a
quick sql script to create a view, but I wanted to do this with
migration to make it easier during deployment.

Thanks,
Kumi

On Fri, Jul 24, 2009 at 4:13 PM, khagimoto[email protected]
wrote:

Is there a way to create a view using ruby migration?

http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#M001934

You can put execute statements in your migration.


Greg D.
http://destiney.com/

I was looking for something equivalent to create_table, but this is
pretty handy. Thanks!

On Fri, Jul 24, 2009 at 5:25 PM, khagimoto[email protected]
wrote:

I was looking for something equivalent to create_table, but this is
pretty handy. Thanks!

I’d offer the observation that scopes in active record can easily
serve the function of views in many cases.


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

@Michael S.
Thanks for the info. I’ll have some warehousing to do in the future,
so rails_sql_view will be perfect!

@Rick DeNatale
I have yet to make use of scopes (still learning… ). Thanks for
pointing me in that direction. I just read this page:
http://api.rubyonrails.org/classes/ActiveRecord/NamedScope/ClassMethods.html
Looks like this is what I should do for what I’m trying to do… pretty
simple!

On Friday 24 July 2009, khagimoto wrote:

Is there a way to create a view using ruby migration? I could run a
quick sql script to create a view, but I wanted to do this with
migration to make it easier during deployment.

Yes, there is a plugin for your purpose

http://github.com/aeden/rails_sql_views

HTH,
Michael


Michael S.
mailto:[email protected]
http://www.schuerig.de/michael/