Top Level Namespace

Defined Under Namespace

Modules: Dynflow Classes: Module, MsgpackMigrationHelper

Instance Method Summary collapse

Instance Method Details

#from_uuid(table_name, column_name) ⇒ Object



6
7
8
# File 'lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb', line 6

def from_uuid(table_name, column_name)
  set_column_type table_name, column_name, String, primary_key: true, size: 36, fixed: true
end

#to_uuid(table_name, column_name) ⇒ Object



2
3
4
# File 'lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb', line 2

def to_uuid(table_name, column_name)
  set_column_type(table_name, column_name, :uuid, :using => "#{column_name}::uuid")
end

#with_foreign_key_recreation(&block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb', line 10

def with_foreign_key_recreation(&block)
  # Drop the foreign key constraints so we can change the column type
  alter_table :dynflow_actions do
    drop_foreign_key [:execution_plan_uuid]
  end
  alter_table :dynflow_steps do
    drop_foreign_key [:execution_plan_uuid]
    drop_foreign_key [:execution_plan_uuid, :action_id], :name => :dynflow_steps_execution_plan_uuid_fkey1
  end
  alter_table :dynflow_delayed_plans do
    drop_foreign_key [:execution_plan_uuid]
  end

  block.call

  # Recreat the foreign key constraints as they were before
  alter_table :dynflow_actions do
    add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans
  end
  alter_table :dynflow_steps do
    add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans
    add_foreign_key [:execution_plan_uuid, :action_id], :dynflow_actions,
                    :name => :dynflow_steps_execution_plan_uuid_fkey1
  end
  alter_table :dynflow_delayed_plans do
    add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans,
                    :name => :dynflow_scheduled_plans_execution_plan_uuid_fkey
  end
end