Browse Source

Improved cleaning up migrations later and applied ux_flow_next_up = 'next_task' for default "Close & tag as spam" macro.

Martin Edenhofer 6 years ago
parent
commit
24a30ad26c

+ 1 - 0
db/migrate/20120101000010_create_ticket.rb

@@ -452,6 +452,7 @@ class CreateTicket < ActiveRecord::Migration[4.2]
       t.string  :name,                   limit: 250,    null: true
       t.text    :perform,                limit: 500.kilobytes + 1, null: false
       t.boolean :active,                                null: false, default: true
+      t.string  :ux_flow_next_up,                       null: false, default: 'none'
       t.string  :note,                   limit: 250,    null: true
       t.integer :updated_by_id,                         null: false
       t.integer :created_by_id,                         null: false

+ 12 - 0
db/migrate/20180611070839_add_ux_flow_next_up_to_macros.rb

@@ -1,5 +1,17 @@
 class AddUxFlowNextUpToMacros < ActiveRecord::Migration[5.1]
   def change
+
+    # return if it's a new setup
+    return if !Setting.find_by(name: 'system_init_done')
+
     add_column :macros, :ux_flow_next_up, :string, default: 'none', null: false
+
+    Macro.connection.schema_cache.clear!
+    Macro.reset_column_information
+
+    macro = Macro.find_by(name: 'Close & Tag as Spam')
+    return if !macro
+    macro.ux_flow_next_up = 'next_task'
+    macro.save!
   end
 end

+ 1 - 0
db/seeds/macros.rb

@@ -13,6 +13,7 @@ Macro.create_if_not_exists(
       value: '',
     },
   },
+  ux_flow_next_up: 'next_task',
   note: 'example macro',
   active: true,
 )