Class: AddHasMagicColumnsTables

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

Class Method Summary collapse

Class Method Details

.downObject



46
47
48
49
50
51
52
# File 'lib/generators/has_magic_columns/install/templates/migration.rb', line 46

def self.down
  drop_table "magic_columns"
  drop_table "magic_attributes"
  drop_table "magic_options"
  drop_table "magic_column_relationships"
  drop_table "magic_attribute_relationships"
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
35
36
37
38
39
40
41
42
43
44
# File 'lib/generators/has_magic_columns/install/templates/migration.rb', line 2

def self.up
  create_table :magic_columns do |t|
    t.column :name,           :string
    t.column :pretty_name,    :string
    t.column :datatype,       :string, :default => "string"
    t.column :default,        :string
    t.column :is_required,    :boolean, :default => false
    t.column :include_blank,  :boolean, :default => false
    t.column :allow_other,    :boolean, :default => true
    t.column :created_at,     :datetime
    t.column :updated_at,     :datetime
  end
  
  create_table :magic_attributes do |t|
    t.column :magic_column_id, :integer
    t.column :magic_option_id, :integer
    t.column :value, :string
    t.column :created_at, :datetime
    t.column :updated_at, :datetime
  end
  
  create_table :magic_options do |t|
    t.column :magic_column_id, :integer
    t.column :value, :string
    t.column :synonym, :string
    t.column :created_at, :datetime
    t.column :updated_at, :datetime
  end
  
  create_table :magic_column_relationships do |t|
    t.column :magic_column_id, :integer
    t.column :owner_id, :integer
    t.column :owner_type, :string
    t.column :created_at, :datetime
    t.column :updated_at, :datetime
  end
  
  create_table :magic_attribute_relationships do |t|
    t.column :magic_attribute_id, :integer
    t.column :owner_id, :integer
    t.column :owner_type, :string
  end   
end