Class: CreateWorkflowProcesses
- Inherits:
-
ActiveRecord::Migration
- Object
- ActiveRecord::Migration
- CreateWorkflowProcesses
- Defined in:
- lib/generators/rails_workflow/install/templates/create_workflow_processes.rb
Instance Method Summary collapse
- #change ⇒ Object
- #check_json_columns ⇒ Object
- #create_columns ⇒ Object
- #create_indexes ⇒ Object
- #create_tables ⇒ Object
Instance Method Details
#change ⇒ Object
4 5 6 7 8 9 |
# File 'lib/generators/rails_workflow/install/templates/create_workflow_processes.rb', line 4 def change create_tables create_columns check_json_columns create_indexes end |
#check_json_columns ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/generators/rails_workflow/install/templates/create_workflow_processes.rb', line 139 def check_json_columns [ [RailsWorkflow::Operation, :dependencies], [RailsWorkflow::OperationTemplate, :dependencies], [RailsWorkflow::Context, :body] ].map do |check| if check[0].columns_hash[check[1].to_s].sql_type == 'json' # change_column check[0].table_name, check[1], "JSON USING #{check[1]}::JSON" change_column check[0].table_name, check[1], :text end end end |
#create_columns ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/generators/rails_workflow/install/templates/create_workflow_processes.rb', line 40 def create_columns { rails_workflow_contexts: [ i[integer parent_id], i[string parent_type], i[text body], i[datetime created_at], i[datetime updated_at] ], rails_workflow_errors: [ i[string ], i[text stack_trace], i[integer parent_id], i[string parent_type], i[datetime created_at], i[datetime updated_at], i[boolean resolved] ], rails_workflow_operation_templates: [ i[string title], i[string version], i[string uuid], i[string tag], i[text source], i[text dependencies], i[string operation_class], i[integer process_template_id], i[datetime created_at], i[datetime updated_at], i[boolean async], i[integer child_process_id], i[integer assignment_id], i[string assignment_type], i[string kind], i[string role], i[string group], i[text instruction], i[boolean is_background], i[string type], i[string partial_name] ], rails_workflow_operations: [ i[integer status], i[boolean async], i[string version], i[string tag], i[string title], i[datetime created_at], i[datetime updated_at], i[integer process_id], i[integer template_id], i[text dependencies], i[integer child_process_id], i[integer assignment_id], i[string assignment_type], i[datetime assigned_at], i[string type], i[boolean is_active], i[datetime completed_at], i[boolean is_background] ], rails_workflow_process_templates: [ i[string title], i[text source], i[string uuid], i[string version], i[string tag], i[string manager_class], i[string process_class], i[datetime created_at], i[datetime updated_at], i[string type], i[string partial_name] ], rails_workflow_processes: [ i[integer status], i[string version], i[string tag], i[boolean async], i[string title], i[datetime created_at], i[datetime updated_at], i[integer template_id], i[string type] ] }.each do |table, columns| columns.map do |column| unless column_exists? table, column[1] add_column table, column[1], column[0] end end end end |
#create_indexes ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/generators/rails_workflow/install/templates/create_workflow_processes.rb', line 26 def create_indexes [ [:rails_workflow_contexts, i[parent_id parent_type], :rw_context_parents], [:rails_workflow_errors, i[parent_id parent_type], :rw_error_parents], i[rails_workflow_operation_templates process_template_id rw_ot_to_pt], i[rails_workflow_operation_templates uuid rw_ot_uuids], i[rails_workflow_process_templates uuid rw_pt_uuids], i[rails_workflow_operations process_id rw_o_process_ids], i[rails_workflow_operations template_id rw_o_template_ids] ].each do |idx| add_index idx[0], idx[1], name: idx[2] unless index_exists? idx[0], idx[1] end end |
#create_tables ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/rails_workflow/install/templates/create_workflow_processes.rb', line 11 def create_tables [ i[workflow_processes rails_workflow_processes], i[workflow_operations rails_workflow_operations], i[workflow_process_templates rails_workflow_process_templates], i[workflow_operation_templates rails_workflow_operation_templates], i[workflow_contexts rails_workflow_contexts], i[workflow_errors rails_workflow_errors] ].map do |names| rename_table names[0], names[1] if table_exists? names[0] create_table names[1] unless table_exists? names[1] end end |