Method: CreateUpdateableViewsInheritance#up

Defined in:
lib/generators/updateable_views_inheritance/templates/create_updateable_views_inheritance.rb

#upObject



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/generators/updateable_views_inheritance/templates/create_updateable_views_inheritance.rb', line 2

def up
  create_table(:updateable_views_inheritance, :id => false) do |t|
    t.column :parent_relation, :string, :null => false
    t.column :child_aggregate_view, :string, :null => false
    t.column :child_relation, :string, :null => false
  end

  execute "ALTER TABLE updateable_views_inheritance ADD PRIMARY KEY (parent_relation, child_aggregate_view, child_relation)"
  execute "ALTER TABLE updateable_views_inheritance ADD UNIQUE (child_aggregate_view)"
  execute "ALTER TABLE updateable_views_inheritance ADD UNIQUE (parent_relation, child_aggregate_view)"
end