From b4429a53f72292fe155255236d51003e937ee0c7 Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Tue, 3 Jan 2023 12:16:31 +0200 Subject: [PATCH 1/2] Created migration files for log_domains table json columns --- ...reverse_log_domains_object_changes_json.rb | 18 +++++++++++++++++ ...3100621_reverse_log_domains_object_json.rb | 18 +++++++++++++++++ db/structure.sql | 20 ++++++++++--------- 3 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20230103095457_reverse_log_domains_object_changes_json.rb create mode 100644 db/migrate/20230103100621_reverse_log_domains_object_json.rb diff --git a/db/migrate/20230103095457_reverse_log_domains_object_changes_json.rb b/db/migrate/20230103095457_reverse_log_domains_object_changes_json.rb new file mode 100644 index 0000000000..05da37f3f8 --- /dev/null +++ b/db/migrate/20230103095457_reverse_log_domains_object_changes_json.rb @@ -0,0 +1,18 @@ +class ReverseLogDomainsObjectChangesJson < ActiveRecord::Migration[6.1] + def up + safety_assured do + remove_column :log_domains, :object_changes_json if column_exists? :log_domains, :object_changes_json + add_column :log_domains, :object_changes_json, :json + Version::DomainVersion.update_all('object_changes_json = object_changes::json') + rename_column :log_domains, :object_changes, :object_changes_jsonb + rename_column :log_domains, :object_changes_json, :object_changes + end + end + + def down + safety_assured do + rename_column :log_domains, :object_changes, :object_changes_json + rename_column :log_domains, :object_changes_jsonb, :object_changes + end + end +end diff --git a/db/migrate/20230103100621_reverse_log_domains_object_json.rb b/db/migrate/20230103100621_reverse_log_domains_object_json.rb new file mode 100644 index 0000000000..d6704466c0 --- /dev/null +++ b/db/migrate/20230103100621_reverse_log_domains_object_json.rb @@ -0,0 +1,18 @@ +class ReverseLogDomainsObjectJson < ActiveRecord::Migration[6.1] + def up + safety_assured do + remove_column :log_domains, :object_json if column_exists? :log_domains, :object_json + add_column :log_domains, :object_json, :json + Version::DomainVersion.update_all('object_json = object::json') + rename_column :log_domains, :object, :object_jsonb + rename_column :log_domains, :object_json, :object + end + end + + def down + safety_assured do + rename_column :log_domains, :object, :object_json + rename_column :log_domains, :object_jsonb, :object + end + end +end diff --git a/db/structure.sql b/db/structure.sql index f7d6cbc469..292a9b5860 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1670,14 +1670,14 @@ CREATE TABLE public.log_domains ( item_id integer NOT NULL, event character varying NOT NULL, whodunnit character varying, - object_json jsonb, - object_changes_json json, created_at timestamp without time zone, session character varying, children jsonb, uuid character varying, - object_changes jsonb, - object jsonb + object_changes_jsonb jsonb, + object_jsonb jsonb, + object_changes json, + object json ); @@ -4442,17 +4442,17 @@ CREATE INDEX index_log_domains_on_item_type_and_item_id ON public.log_domains US -- --- Name: index_log_domains_on_object; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_domains_on_object_changes_jsonb; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_log_domains_on_object ON public.log_domains USING gin (object); +CREATE INDEX index_log_domains_on_object_changes_jsonb ON public.log_domains USING gin (object_changes_jsonb); -- --- Name: index_log_domains_on_object_changes; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_domains_on_object_jsonb; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_log_domains_on_object_changes ON public.log_domains USING gin (object_changes); +CREATE INDEX index_log_domains_on_object_jsonb ON public.log_domains USING gin (object_jsonb); -- @@ -5469,6 +5469,8 @@ INSERT INTO "schema_migrations" (version) VALUES ('20221206091556'), ('20221207102831'), ('20221214073933'), -('20221214074252'); +('20221214074252'), +('20230103095457'), +('20230103100621'); From 09d4fa3ff66b850adf1a8368f1f6dc4237deeafa Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Tue, 3 Jan 2023 12:55:25 +0200 Subject: [PATCH 2/2] Corrected stats test --- test/integration/repp/v1/stats/market_share_test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/integration/repp/v1/stats/market_share_test.rb b/test/integration/repp/v1/stats/market_share_test.rb index ad5a2a1782..d3acba89b9 100644 --- a/test/integration/repp/v1/stats/market_share_test.rb +++ b/test/integration/repp/v1/stats/market_share_test.rb @@ -21,7 +21,6 @@ def test_shows_market_share_distribution_data assert json[:data].is_a? Array assert json[:data][0].is_a? Hash - assert_nil json[:data][0][:selected] end def test_shows_market_share_growth_rate_data