2020-06-22 22:47:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class RepositoryTableStateUpdate < ActiveRecord::Migration[6.0]
|
2020-06-24 15:51:24 +08:00
|
|
|
class TempStateModel < ApplicationRecord
|
|
|
|
self.table_name = 'repository_table_states'
|
|
|
|
end
|
|
|
|
|
2020-06-22 22:47:42 +08:00
|
|
|
def up
|
2020-06-24 15:51:24 +08:00
|
|
|
TempStateModel.find_each do |table_state|
|
2020-06-22 22:47:42 +08:00
|
|
|
state = table_state.state
|
|
|
|
order_state = state['order'][0][0]
|
|
|
|
state['order'][0][0] = order_state + 2 if order_state > 5
|
|
|
|
2.times do
|
|
|
|
state['columns'].insert(6,
|
|
|
|
'search' => {
|
|
|
|
'regex' => false, 'smart' => true, 'search' => '', 'caseInsensitive' => true
|
|
|
|
},
|
|
|
|
'visible' => false)
|
|
|
|
end
|
|
|
|
state['ColReorder'] = state['ColReorder'].map { |i| i > 5 ? i + 2 : i } + [6, 7]
|
|
|
|
table_state.update(state: state)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-06-24 16:00:34 +08:00
|
|
|
|