diff --git a/Gemfile b/Gemfile index 4dd59eabf..e93041609 100644 --- a/Gemfile +++ b/Gemfile @@ -69,8 +69,7 @@ gem "sprockets", "~> 3.7", ">= 3.7.2" gem 'uuid', '~> 2.3', '>= 2.3.9' gem 'strong_migrations', '~> 0.6.0' gem 'crawler_detect' - - +gem 'lhm', '~> 2.2' group :development, :test do gem "rspec-rails", "~> 3.8", ">= 3.8.2" diff --git a/Gemfile.lock b/Gemfile.lock index f4f82ec9f..7ae6a9476 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -59,7 +59,7 @@ GEM addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) ansi (1.5.0) - apollo-federation (1.0.0) + apollo-federation (1.0.1) google-protobuf (~> 3.7) graphql (~> 1.9.8) arel (9.0.0) @@ -139,7 +139,7 @@ GEM builder (3.2.4) byebug (11.1.1) cancancan (2.3.0) - capybara (3.30.0) + capybara (3.31.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -170,6 +170,7 @@ GEM crack (0.4.3) safe_yaml (~> 1.0.0) crass (1.0.6) + crawler_detect (0.1.11) csl (1.5.1) namae (~> 1.0) csl-styles (1.0.1.10) @@ -177,7 +178,7 @@ GEM css_parser (1.7.1) addressable dalli (2.7.10) - database_cleaner (1.7.0) + database_cleaner (1.8.1) debug_inspector (0.0.3) diff-lcs (1.3) diffy (3.3.0) @@ -241,7 +242,7 @@ GEM globalid (0.4.2) activesupport (>= 4.2.0) google-protobuf (3.10.0.rc.1) - graphql (1.9.18) + graphql (1.9.19) graphql-batch (0.4.2) graphql (>= 1.3, < 2) promise.rb (~> 0.7.2) @@ -280,19 +281,20 @@ GEM oj (~> 3) optimist (~> 3) jwt (2.2.1) - kaminari (1.1.1) + kaminari (1.2.0) activesupport (>= 4.1.0) - kaminari-actionview (= 1.1.1) - kaminari-activerecord (= 1.1.1) - kaminari-core (= 1.1.1) - kaminari-actionview (1.1.1) + kaminari-actionview (= 1.2.0) + kaminari-activerecord (= 1.2.0) + kaminari-core (= 1.2.0) + kaminari-actionview (1.2.0) actionview - kaminari-core (= 1.1.1) - kaminari-activerecord (1.1.1) + kaminari-core (= 1.2.0) + kaminari-activerecord (1.2.0) activerecord - kaminari-core (= 1.1.1) - kaminari-core (1.1.1) + kaminari-core (= 1.2.0) + kaminari-core (1.2.0) latex-decode (0.3.1) + lhm (2.2.0) link_header (0.0.8) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) @@ -332,7 +334,7 @@ GEM mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2019.1009) - mimemagic (0.3.3) + mimemagic (0.3.4) mini_magick (4.10.1) mini_mime (1.0.2) mini_portile2 (2.4.0) @@ -348,7 +350,7 @@ GEM nio4r (2.5.2) nokogiri (1.10.7) mini_portile2 (~> 2.4.0) - oj (3.10.1) + oj (3.10.2) oj_mimic_json (1.0.1) optimist (3.0.0) pandoc-ruby (2.0.2) @@ -368,7 +370,7 @@ GEM pwqgen.rb (0.1.0) docopt (~> 0.5) sysrandom - rack (2.1.1) + rack (2.1.2) rack-accept (0.4.5) rack (>= 0.4) rack-cors (1.1.1) @@ -513,7 +515,7 @@ GEM regexp_parser (~> 1.3, >= 1.3.0) strip_attributes (1.9.0) activemodel (>= 3.0, < 7.0) - strong_migrations (0.6.0) + strong_migrations (0.6.1) activerecord (>= 5) sxp (1.1.0) rdf (~> 3.1) @@ -573,6 +575,7 @@ DEPENDENCIES commonmarker (~> 0.17.9) countries (~> 2.1, >= 2.1.2) country_select (~> 3.1) + crawler_detect dalli (~> 2.7, >= 2.7.6) database_cleaner diffy (~> 3.2, >= 3.2.1) @@ -602,6 +605,7 @@ DEPENDENCIES jsonlint (~> 0.3.0) jwt kaminari (~> 1.0, >= 1.0.1) + lhm (~> 2.2) listen (>= 3.0.5, < 3.2) lograge (~> 0.11.2) logstash-event (~> 1.2, >= 1.2.02) diff --git a/db/migrate/20200131180609_add_events_properties.rb b/db/migrate/20200131180609_add_events_properties.rb index 26805d225..53aaaa382 100644 --- a/db/migrate/20200131180609_add_events_properties.rb +++ b/db/migrate/20200131180609_add_events_properties.rb @@ -1,12 +1,27 @@ # frozen_string_literal: true +require 'lhm' + class AddEventsProperties < ActiveRecord::Migration[5.2] - def change - add_column :events, :source_doi, :text - add_column :events, :target_doi, :text - add_column :events, :source_relation_type_id, :string, limit: 191 - add_column :events, :target_relation_type_id, :string, limit: 191 - add_index :events, [:source_doi, :source_relation_type_id], name: "index_events_on_source_doi", length: { source_doi: 100, source_relation_type_id: 191 } - add_index :events, [:target_doi, :target_relation_type_id], name: "index_events_on_target_doi", length: { target_doi: 100, target_relation_type_id: 191 } + def up + Lhm.change_table :events do |m| + m.add_column :source_doi, "TEXT" + m.add_column :target_doi, "TEXT" + m.add_column :source_relation_type_id, "VARCHAR(191)" + m.add_column :target_relation_type_id, "VARCHAR(191)" + m.add_index ["source_doi(100)", "source_relation_type_id(191)"], :index_events_on_source_doi + m.add_index ["target_doi(100)", "target_relation_type_id(191)"], :index_events_on_target_doi + end + end + + def down + Lhm.change_table :events do |m| + m.remove_column :source_doi + m.remove_column :target_doi + m.remove_column :source_relation_type_id + m.remove_column :target_relation_type_id + m.remove_index ["source_doi(100)", "source_relation_type_id(191)"], :index_events_on_source_doi + m.remove_index ["target_doi(100)", "target_relation_type_id(191)"], :index_events_on_target_doi + end end end