Class: AddHasDynamicColumns

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

Class Method Summary collapse

Class Method Details

.downObject



40
41
42
# File 'lib/generators/has_dynamic_columns/templates/migration.rb', line 40

def self.down
	drop_table :dynamic_columns
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
# File 'lib/generators/has_dynamic_columns/templates/migration.rb', line 2

def self.up
	create_table :dynamic_columns do |t|
		t.integer :field_scope_id
		t.string :field_scope_type

		t.string :dynamic_type
		t.string :key
		t.string :data_type

		t.timestamps null: false
	end
	add_index(:dynamic_columns, [:field_scope_id, :field_scope_type, :dynamic_type], name: 'index1')
	create_table :dynamic_column_validations do |t|
		t.integer :dynamic_column_id

		t.string :error
		t.string :regexp

		t.timestamps null: false
	end
	create_table :dynamic_column_options do |t|
		t.integer :dynamic_column_id
		t.string :key

		t.timestamps null: false
	end
	create_table :dynamic_column_data do |t|
		t.string :owner_type
		t.integer :owner_id
		t.integer :dynamic_column_id
		t.integer :dynamic_column_option_id
		t.string :value

		t.timestamps null: false
	end
	add_index(:dynamic_column_data, [:owner_id, :owner_type, :dynamic_column_id], name: 'index2')
end