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

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

You can put execute statements in your migration.

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.

Yes, there is a plugin for your purpose

http://github.com/aeden/rails_sql_views

HTH, Michael

@Michael Schuerig 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!