Class: ActsAsGraphDiagramMigration

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

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.downObject



20
21
22
# File 'lib/generators/templates/migration.rb', line 20

def self.down
  drop_table :edges
end

.upObject



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

def self.up
  create_table :edges, force: true do |t|
    t.string :comment, default: ''
    t.integer :figure, default: 0
    t.integer :lower_figure, default: 0
    t.integer :higher_figure, default: 0
    t.boolean :directed, default: true
    t.references :destination, polymorphic: true, null: true
    t.references :departure, polymorphic: true, null: true
    t.timestamps
  end

  add_index :edges, %w[departure_id departure_type], name: 'fk_edges_departure'
  add_index :edges, %w[destination_id destination_type], name: 'fk_edges_destination'
end