Class: CreateCustomAttributes

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

Class Method Summary collapse

Class Method Details

.downObject



21
22
23
24
25
26
# File 'lib/generators/custom_attributes/templates/create_custom_attributes.rb', line 21

def self.down
  remove_index :custom_attributes, [:item_type, :item_id]
  drop_table :custom_attributes
  remove_index :custom_attribute_values, [:custom_attribute_id]
  drop_table :custom_attribute_values
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/generators/custom_attributes/templates/create_custom_attributes.rb', line 2

def self.up
  create_table :custom_attributes do |t|
    t.string :name
    t.string :owner
    t.string :scope_type
    t.string :scope_id
    t.timestamps
  end
  add_index :custom_attributes, [:scope_type, :scope_id]
  
  create_table :custom_attribute_values do |t|
    t.integer :custom_attribute_id
    t.string :owner_id
    t.string :value
    t.timestamps
  end
  add_index :custom_attribute_values, :custom_attribute_id
end