@@ -2,6 +2,7 @@ class CreateWorkflowProcesses < ActiveRecord::Migration
22 def change
33 create_tables
44 create_columns
5+ check_json_columns
56 create_indexes
67 end
78
@@ -59,6 +60,7 @@ def create_columns
5960
6061 :rails_workflow_operation_templates => [
6162 [ :string , :title ] ,
63+ [ :string , :version ] ,
6264 [ :text , :source ] ,
6365 [ :json , :dependencies ] ,
6466 [ :string , :operation_class ] ,
@@ -81,6 +83,8 @@ def create_columns
8183 :rails_workflow_operations => [
8284 [ :integer , :status ] ,
8385 [ :boolean , :async ] ,
86+ [ :string , :version ] ,
87+ [ :string , :tag ] ,
8488 [ :string , :title ] ,
8589 [ :datetime , :created_at ] ,
8690 [ :datetime , :updated_at ] ,
@@ -100,6 +104,7 @@ def create_columns
100104 :rails_workflow_process_templates => [
101105 [ :string , :title ] ,
102106 [ :text , :source ] ,
107+ [ :string , :version ] ,
103108 [ :string , :manager_class ] ,
104109 [ :string , :process_class ] ,
105110 [ :datetime , :created_at ] ,
@@ -110,6 +115,8 @@ def create_columns
110115
111116 :rails_workflow_processes => [
112117 [ :integer , :status ] ,
118+ [ :string , :version ] ,
119+ [ :string , :tag ] ,
113120 [ :boolean , :async ] ,
114121 [ :string , :title ] ,
115122 [ :datetime , :created_at ] ,
@@ -119,12 +126,24 @@ def create_columns
119126 ]
120127 } . each do |table , columns |
121128 columns . map do |column |
122- unless column_exists? talbe , column [ 1 ]
129+ unless column_exists? table , column [ 1 ]
123130 add_column table , column [ 1 ] , column [ 0 ]
124131 end
125132 end
126133
127134 end
128135
129136 end
137+
138+ def check_json_columns
139+ [
140+ [ RailsWorkflow ::Operation , :dependencies ] ,
141+ [ RailsWorkflow ::OperationTemplates , :dependencies ] ,
142+ [ RailsWorkflow ::Context , :body ]
143+ ] . map do |check |
144+ if check [ 0 ] . columns_hash [ check [ 1 ] . to_s ] . sql_type != "json"
145+ change_column check [ 0 ] . table_name , check [ 1 ] , "JSON USING #{ check [ 1 ] } ::JSON"
146+ end
147+ end
148+ end
130149end
0 commit comments