Class: CreateUpdateableViewsInheritance

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/updateable_views_inheritance/templates/create_updateable_views_inheritance.rb

Instance Method Summary collapse

Instance Method Details

#downObject



14
15
16
# File 'lib/generators/updateable_views_inheritance/templates/create_updateable_views_inheritance.rb', line 14

def down
  drop_table :updateable_views_inheritance
end

#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