Skip to content

Commit

Permalink
use lhm gem for migrations. #409
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Feb 1, 2020
1 parent 282b0f6 commit c1b7391
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 26 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
38 changes: 21 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -170,14 +170,15 @@ 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)
csl (~> 1.0)
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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
29 changes: 22 additions & 7 deletions db/migrate/20200131180609_add_events_properties.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c1b7391

Please sign in to comment.