From 0fe4ee0eae7a4668966d6871941d6e2f2e153540 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Mon, 22 Jun 2020 16:47:42 +0200 Subject: [PATCH 1/3] Add migration for repository states --- ...622155632_repository_table_state_update.rb | 20 +++++++++++++++++++ db/structure.sql | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20200622155632_repository_table_state_update.rb diff --git a/db/migrate/20200622155632_repository_table_state_update.rb b/db/migrate/20200622155632_repository_table_state_update.rb new file mode 100644 index 000000000..0a942fa53 --- /dev/null +++ b/db/migrate/20200622155632_repository_table_state_update.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class RepositoryTableStateUpdate < ActiveRecord::Migration[6.0] + def up + RepositoryTableState.all.each do |table_state| + 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 diff --git a/db/structure.sql b/db/structure.sql index 4da24473c..6e6f5630f 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -7266,7 +7266,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20200326114643'), ('20200331183640'), ('20200603125407'), -('20200604210943'); - +('20200604210943'), +('20200622155632'); From 0dff84cae0efda2cd8443433e21ce2bc40f94e37 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Wed, 24 Jun 2020 09:51:24 +0200 Subject: [PATCH 2/3] Update migration --- db/migrate/20200622155632_repository_table_state_update.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/migrate/20200622155632_repository_table_state_update.rb b/db/migrate/20200622155632_repository_table_state_update.rb index 0a942fa53..b80497284 100644 --- a/db/migrate/20200622155632_repository_table_state_update.rb +++ b/db/migrate/20200622155632_repository_table_state_update.rb @@ -1,8 +1,12 @@ # frozen_string_literal: true class RepositoryTableStateUpdate < ActiveRecord::Migration[6.0] + class TempStateModel < ApplicationRecord + self.table_name = 'repository_table_states' + end + def up - RepositoryTableState.all.each do |table_state| + TempStateModel.find_each do |table_state| state = table_state.state order_state = state['order'][0][0] state['order'][0][0] = order_state + 2 if order_state > 5 From d940d1e43d260d5792686fabbfb1cee4b4d02d7e Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Wed, 24 Jun 2020 10:00:34 +0200 Subject: [PATCH 3/3] Add new line --- db/migrate/20200622155632_repository_table_state_update.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/migrate/20200622155632_repository_table_state_update.rb b/db/migrate/20200622155632_repository_table_state_update.rb index b80497284..92f797946 100644 --- a/db/migrate/20200622155632_repository_table_state_update.rb +++ b/db/migrate/20200622155632_repository_table_state_update.rb @@ -22,3 +22,4 @@ class RepositoryTableStateUpdate < ActiveRecord::Migration[6.0] end end end +