Class: UpdateProcessAssociations

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

Constant Summary

Constants included from Ductwork::MigrationHelper

Ductwork::MigrationHelper::AVAILABILITY_CLAIM_INDEX_NAME, Ductwork::MigrationHelper::AVAILABILITY_CLAIM_INDEX_NAMES, Ductwork::MigrationHelper::AVAILABILITY_CLAIM_INDEX_NAME_V2

Instance Method Summary collapse

Methods included from Ductwork::MigrationHelper

#add_availability_claim_index, #add_index_online, #belongs_to, #create_ductwork_table, #drop_invalid_index, #ensure_ddl_transaction_disabled!, #mysql?, #postgresql?, #remove_availability_claim_index, #remove_index_online, #swap_availability_claim_index, #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
# File 'lib/generators/ductwork/update/templates/db/update_process_associations.rb', line 4

def change
  remove_column :ductwork_availabilities, :process_id, :integer

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

  add_reference :ductwork_availabilities, :process, **options
  add_index :ductwork_availabilities, %i[id process_id]

  remove_column :ductwork_executions, :process_id, :integer
end