Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
FI-903: replace data mapper (onc-healthit#504)
Browse files Browse the repository at this point in the history
* replace DataMapper with ActiveRecord

* address PR comments

* move scripts to bin directory
  • Loading branch information
Jammjammjamm authored Nov 5, 2020
1 parent 0e34a77 commit d1e9b92
Show file tree
Hide file tree
Showing 153 changed files with 1,890 additions and 1,552 deletions.
1 change: 1 addition & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: "2" # required to adjust maintainability checks
exclude_patterns:
- "!**/test/"
- "!db/**/*"
checks:
argument-count:
enabled: true
Expand Down
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AllCops:
- 'vendor/**/*'
- 'node_modules/**/*'
- '.git/**/*'
- 'db/**/*'

Layout/MultilineMethodCallIndentation:
EnforcedStyle: 'indented'
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ before_script:
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script:
- RACK_ENV=test bundle exec rake db:create db:schema:load
- bundle exec rake
# For unknown reasons, the test-reporter fails when using docker if run in an
# after_script section
- ./cc-test-reporter after-build -t simplecov --exit-code $TRAVIS_TEST_RESULT
- docker-compose run ruby_server bundle exec rake
- docker-compose run ruby_server ./bin/run_tests.sh
- bundle exec rubocop
notifications:
email:
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ COPY config* /var/www/inferno/
COPY Rakefile /var/www/inferno/
COPY test /var/www/inferno/test
COPY lib /var/www/inferno/lib
COPY db /var/www/inferno/db
COPY bin /var/www/inferno/bin

### Set up environment

ENV APP_ENV=production
ENV RACK_ENV=production
EXPOSE 4567

CMD ["bundle", "exec", "rackup", "-o", "0.0.0.0"]
CMD ["./bin/run.sh"]
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

source 'https://rubygems.org'

gem 'activerecord', '~> 5.2'
gem 'addressable'
gem 'ast'
gem 'base62-rb'
gem 'bloomer'
gem 'colorize'
gem 'data_mapper'
gem 'dm-sqlite-adapter'
gem 'fhir_client'
gem 'jwt'
gem 'kramdown'
Expand All @@ -23,10 +22,12 @@ gem 'selenium-webdriver'
gem 'sinatra'
gem 'sinatra-contrib'
gem 'sqlite3'
gem 'standalone_migrations', '~> 6.0'
gem 'thin'
gem 'time_difference'

group :test do
gem 'database_cleaner-active_record'
gem 'minitest'
gem 'rack-test'
gem 'rubocop', require: false
Expand Down
106 changes: 49 additions & 57 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
GEM
remote: https://rubygems.org/
specs:
actionpack (5.2.4.3)
actionview (= 5.2.4.3)
activesupport (= 5.2.4.3)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.4.3)
activesupport (= 5.2.4.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activemodel (5.2.4.3)
activesupport (= 5.2.4.3)
activerecord (5.2.4.3)
activemodel (= 5.2.4.3)
activesupport (= 5.2.4.3)
arel (>= 9.0)
activesupport (5.2.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0)
ast (2.4.0)
backports (3.15.0)
base62-rb (0.3.1)
bcp47 (0.3.3)
i18n
bcrypt (3.1.13)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
bitarray (1.2.0)
bloomer (1.0.0)
bitarray
msgpack
builder (3.2.4)
byebug (11.0.1)
childprocess (2.0.0)
rake (< 13.0)
Expand All @@ -28,63 +46,20 @@ GEM
concurrent-ruby (1.1.6)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.6)
daemons (1.3.1)
data_mapper (1.2.0)
dm-aggregates (~> 1.2.0)
dm-constraints (~> 1.2.0)
dm-core (~> 1.2.0)
dm-migrations (~> 1.2.0)
dm-serializer (~> 1.2.0)
dm-timestamps (~> 1.2.0)
dm-transactions (~> 1.2.0)
dm-types (~> 1.2.0)
dm-validations (~> 1.2.0)
data_objects (0.10.17)
addressable (~> 2.1)
database_cleaner (1.8.5)
database_cleaner-active_record (1.8.0)
activerecord
database_cleaner (~> 1.8.0)
date_time_precision (0.8.1)
dm-aggregates (1.2.0)
dm-core (~> 1.2.0)
dm-constraints (1.2.0)
dm-core (~> 1.2.0)
dm-core (1.2.1)
addressable (~> 2.3)
dm-do-adapter (1.2.0)
data_objects (~> 0.10.6)
dm-core (~> 1.2.0)
dm-migrations (1.2.0)
dm-core (~> 1.2.0)
dm-serializer (1.2.2)
dm-core (~> 1.2.0)
fastercsv (~> 1.5)
json (~> 1.6)
json_pure (~> 1.6)
multi_json (~> 1.0)
dm-sqlite-adapter (1.2.0)
dm-do-adapter (~> 1.2.0)
do_sqlite3 (~> 0.10.6)
dm-timestamps (1.2.0)
dm-core (~> 1.2.0)
dm-transactions (1.2.0)
dm-core (~> 1.2.0)
dm-types (1.2.2)
bcrypt-ruby (~> 3.0)
dm-core (~> 1.2.0)
fastercsv (~> 1.5)
json (~> 1.6)
multi_json (~> 1.0)
stringex (~> 1.4)
uuidtools (~> 2.1)
dm-validations (1.2.0)
dm-core (~> 1.2.0)
do_sqlite3 (0.10.17)
data_objects (= 0.10.17)
docile (1.3.2)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
erubi (1.9.0)
eventmachine (1.2.7)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
fastercsv (1.5.5)
fhir_client (4.0.3)
activesupport (>= 3)
addressable (>= 2.3)
Expand Down Expand Up @@ -119,10 +94,12 @@ GEM
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.3)
json (1.8.6)
json_pure (1.8.6)
jwt (2.2.1)
kramdown (2.3.0)
rexml
loofah (2.7.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
method_source (0.9.2)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
Expand Down Expand Up @@ -158,6 +135,17 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.4.3)
actionpack (= 5.2.4.3)
activesupport (= 5.2.4.3)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
rake (12.3.3)
rb-readline (0.5.5)
Expand Down Expand Up @@ -201,11 +189,15 @@ GEM
sinatra (= 2.0.7)
tilt (~> 2.0)
sqlite3 (1.4.1)
stringex (1.5.1)
standalone_migrations (6.0.0)
activerecord (>= 4.2.7, < 6.1.0, != 5.2.3.rc1, != 5.2.3)
railties (>= 4.2.7, < 6.1.0, != 5.2.3.rc1, != 5.2.3)
rake (>= 10.0)
thin (1.7.2)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
time_difference (0.7.0)
Expand All @@ -216,7 +208,6 @@ GEM
unf_ext
unf_ext (0.0.7.6)
unicode-display_width (1.6.0)
uuidtools (2.1.5)
webmock (3.7.6)
addressable (>= 2.3.6)
crack (>= 0.3.2)
Expand All @@ -226,13 +217,13 @@ PLATFORMS
ruby

DEPENDENCIES
activerecord (~> 5.2)
addressable
ast
base62-rb
bloomer
colorize
data_mapper
dm-sqlite-adapter
database_cleaner-active_record
fhir_client
jwt
kramdown
Expand All @@ -251,6 +242,7 @@ DEPENDENCIES
sinatra
sinatra-contrib
sqlite3
standalone_migrations (~> 6.0)
thin
time_difference
webmock
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ And run the following commands from the terminal:
git clone https://github.com/onc-healthit/inferno
cd inferno
bundle install
bundle exec rake db:create db:schema:load
bundle exec rackup
```

Expand All @@ -61,6 +62,26 @@ Deployment on a remote server can be done by using a modified form of the Docker

Please see the file [deployment-configuration.md](https://github.com/onc-healthit/inferno/blob/master/deployment-configuration.md) for details.

#### Upgrading Inferno

If an Inferno update makes changes to the database schema, migrations will have
to be run when updating. Run migrations with:

```sh
bundle exec rake db:migrate
```

The above will migrate the development database. To migrate a production or test
database, use:

```sh
RACK_ENV=production bundle exec rake db:migrate
RACK_ENV=test bundle exec rake db:migrate
```

If you are using the provided inferno docker image, migrations will be run
automatically.

### Reference Implementation

While it is recommended that users install Inferno locally, a reference implementation of Inferno is hosted at https://inferno.healthit.gov
Expand All @@ -76,6 +97,7 @@ Inferno has been tested on the latest versions of Chrome, Firefox, Safari, and E
Inferno contains a robust set of self-tests to ensure that the test clients conform to the specification and performs as intended. To run these tests, execute the following command:

```sh
RACK_ENV=test bundle exec rake db:create db:schema:load
bundle exec rake test
```

Expand Down
3 changes: 3 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

require 'rake/testtask'
require 'rubocop/rake_task'
require 'standalone_migrations'

StandaloneMigrations::Tasks.load_tasks

task :default do
ENV['RACK_ENV'] = 'test'
Expand Down
4 changes: 4 additions & 0 deletions bin/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

bundle exec rake db:create db:migrate
bundle exec rackup -o 0.0.0.0
3 changes: 3 additions & 0 deletions bin/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

RACK_ENV=test bundle exec rake db:create db:migrate test
17 changes: 17 additions & 0 deletions db/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
development:
adapter: sqlite3
database: data/development_data.db
pool: 10
timeout: 5000

production:
adapter: sqlite3
database: data/production_data.db
pool: 10
timeout: 5000

test: &test
adapter: sqlite3
database: data/test_data.db
pool: 10
timeout: 5000
Loading

0 comments on commit d1e9b92

Please sign in to comment.