Class: AssociateStepsToBranches

Inherits:
Ductwork::Migration show all
Defined in:
lib/generators/ductwork/update/templates/db/associate_steps_to_branches.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
# File 'lib/generators/ductwork/update/templates/db/associate_steps_to_branches.rb', line 4

def change
  options = if postgresql?
              {
                type: uuid_column_type,
                index: true,
                null: true,
                foreign_key: { to_table: :ductwork_branches },
              }
            else
              {
                type: uuid_column_type,
                limit: 36,
                index: true,
                null: true,
                foreign_key: { to_table: :ductwork_branches },
              }
            end

  add_reference :ductwork_steps, :branch, **options
end