Skip to content

Commit

Permalink
Merge pull request #2518 from internetee/reverse-log-domains-json-data
Browse files Browse the repository at this point in the history
Created migration files for log_domains table json columns
  • Loading branch information
vohmar authored Jan 9, 2023
2 parents d5cb379 + 09d4fa3 commit ca5dea9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions db/migrate/20230103100621_reverse_log_domains_object_json.rb
Original file line number Diff line number Diff line change
@@ -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
20 changes: 11 additions & 9 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1664,14 +1664,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
);


Expand Down Expand Up @@ -4283,17 +4283,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);


--
Expand Down Expand Up @@ -5309,6 +5309,8 @@ INSERT INTO "schema_migrations" (version) VALUES
('20221206091556'),
('20221207102831'),
('20221214073933'),
('20221214074252');
('20221214074252'),
('20230103095457'),
('20230103100621');


1 change: 0 additions & 1 deletion test/integration/repp/v1/stats/market_share_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca5dea9

Please sign in to comment.