Class: CreateProductsTables

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/permissify/install/templates/create_products_tables.rb

Instance Method Summary collapse

Instance Method Details

#downObject



36
37
38
39
40
41
42
43
# File 'lib/generators/permissify/install/templates/create_products_tables.rb', line 36

def down
  drop_table :admins_products
  drop_table :dealers_products
  drop_table :corporations_products
  drop_table :brands_products
  drop_table :merchants_products
  drop_table :products
end

#upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/permissify/install/templates/create_products_tables.rb', line 2

def up
  
  create_table  :products, :force => true do |t|
    t.string    :name
    t.text      :permissions
  end
  
  create_table :merchants_products, :id => false, :force => true do |t|
    t.integer :merchant_id, :null => false
    t.integer :product_id, :null => false
  end
  
  create_table :brands_products, :id => false, :force => true do |t|
    t.integer :brand_id, :null => false
    t.integer :product_id, :null => false
  end
  
  create_table :corporations_products, :id => false, :force => true do |t|
    t.integer :corporation_id, :null => false
    t.integer :product_id, :null => false
  end
  
  create_table :dealers_products, :id => false, :force => true do |t|
    t.integer :dealer_id, :null => false
    t.integer :product_id, :null => false
  end
  
  create_table :admins_products, :id => false, :force => true do |t|
    t.integer :admin_id, :null => false
    t.integer :product_id, :null => false
  end

end