Skip to content

Commit

Permalink
Added a method for generating a PK for the view.
Browse files Browse the repository at this point in the history
  • Loading branch information
barendt committed Nov 28, 2012
1 parent b33b0ee commit a6c29f7
Showing 1 changed file with 9 additions and 0 deletions.
Expand Up @@ -29,6 +29,15 @@ def create_view(name, select_query, options={})
create_sql << " WITH #{options[:check_option]} CHECK OPTION" if options[:check_option]
execute create_sql
end

if options[:primary_key]
create_primary_key_for_view name, options[:primary_key]
end
end

def create_primary_key_for_view(name, primary_key)
sql = "ALTER VIEW #{quote_table_name(name)} ADD CONSTRAINT #{quote_table_name(name)}_pk PRIMARY KEY(#{primary_key}) DISABLE"
execute sql
end

# Also creates a view, with the specific purpose of remapping column names
Expand Down

0 comments on commit a6c29f7

Please sign in to comment.