Class: CreateFieldHierarchies

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/templates/migrations/create_field_hierarchies.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/generators/templates/migrations/create_field_hierarchies.rb', line 2

def change
  create_table :field_hierarchies, id: false do |t|
    t.integer :ancestor_id, null: false
    t.integer :descendant_id, null: false
    t.integer :generations, null: false
  end

  add_index :field_hierarchies, [:ancestor_id, :descendant_id, :generations],
    unique: true,
    name: "field_anc_desc_idx"

  add_index :field_hierarchies, [:descendant_id],
    name: "field_desc_idx"
end