Skip to content

Instantly share code, notes, and snippets.

@nicolasiensen
Last active December 23, 2015 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolasiensen/6610444 to your computer and use it in GitHub Desktop.
Save nicolasiensen/6610444 to your computer and use it in GitHub Desktop.
class CreateViewFacts < ActiveRecord::Migration
def up
create_view :facts, "
SELECT c.id, c.created_at, c.name, c.description_html, c.link, c.mobilization_id, 'campaigns' as relname FROM campaigns c
UNION ALL
SELECT p.id, p.created_at, p.name, p.description as description_html, p.link, p.mobilization_id, 'problems' as relname FROM problems p;"
end
def down
drop_view :facts
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment