Class: CreateDuctworkTransitions

Inherits:
Ductwork::Migration show all
Defined in:
lib/generators/ductwork/update/templates/db/create_ductwork_transitions.rb,
lib/generators/ductwork/install/templates/db/create_ductwork_transitions.rb

Instance Method Summary collapse

Methods included from Ductwork::MigrationHelper

#belongs_to, #create_ductwork_table, #mysql?, #postgresql?, #uuid_column_type

Instance Method Details

#changeObject



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
# File 'lib/generators/ductwork/update/templates/db/create_ductwork_transitions.rb', line 4

def change
  create_ductwork_table :ductwork_transitions do |table|
    belongs_to(
      table,
      :branches,
      index: true,
      null: false,
      foreign_key: { to_table: :ductwork_branches }
    )
    belongs_to(
      table,
      :in_step,
      index: true,
      null: false,
      foreign_key: { to_table: :ductwork_steps }
    )
    belongs_to(
      table,
      :out_step,
      index: true,
      null: true,
      foreign_key: { to_table: :ductwork_steps }
    )
    table.datetime :started_at, null: false
    table.datetime :completed_at
    table.timestamps null: false
  end
end