Skip to content

Commit

Permalink
Merge pull request #1103 from ctti-clinicaltrials/kostik/remove-depen…
Browse files Browse the repository at this point in the history
…dency-for-connectionsyml/AACT-555

Kostik/remove dependency for connectionsyml/aact 555
  • Loading branch information
micronix authored Nov 29, 2023
2 parents 0e3911f + 47a2d89 commit 7ea2e69
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 29 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
config/connections.yml
public/static
.git
14 changes: 1 addition & 13 deletions .github/workflows/build-and-test-not-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,7 @@ jobs:
PGPASSWORD=password psql -h localhost -U rails -d aact_admin_test < db/admin_structure.sql
PGPASSWORD=password psql -h localhost -U rails -d aact_public_test < db/public_structure.sql
# Add or replace config/connections.yml file steps here
- name: Build config/connections.yml
run: |
echo "public:" >> config/connections.yml
echo " encoding: utf8" >> config/connections.yml
echo " adapter: postgresql" >> config/connections.yml
echo " host: localhost" >> config/connections.yml
echo " port: 5432" >> config/connections.yml
echo " database: aact_public_test" >> config/connections.yml
echo " user: rails" >> config/connections.yml
echo " password: password" >> config/connections.yml
# Add or replace test runners here
- name: Run tests
run: |
bundle exec rspec
bundle exec rspec
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ server.env
.env
*.secret
.byebug_history
/config/connections.yml
data
/public/static/documentation/schema.dot
/storage
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ RUN adduser --disabled-password aact && chown -R aact /app

COPY . /app

RUN ln -s /config/connections.yml /app/config/connections.yml

# Switch to the user
USER aact
Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,7 @@ export DIGITALOCEAN_BUCKET=aact-dev
Example: `export PATH=$PATH:/Library/PostgreSQL/13/bin`
https://wikimatze.de/installing-postgresql-gem-under-ubuntu-and-mac/

9. Use the "connections.yml.example" file (see in config directory) and copy content of it to the file "connections.yml" (most likely you will need to create connections.yml in the same folder) and just update what needs to be updated for the local environment.
In the terminal, type `cp connections.yml.example connections.yml` (that command doesn't work on linux Ubuntu).
The file called "connections.yml" is mainly for running a docker container but it's called on by the Util::DbManager model when it initializes so you will get an error if it's not there when the model is called. That model manages database changes.
10. In the database.yml file, which is in config folder, lines 1-32 should look like:
9. In the database.yml file, which is in config folder, lines 1-32 should look like:

```
default: &default
Expand Down Expand Up @@ -171,7 +167,7 @@ development:
database: aact_public
```
11. Create databases and run migrations
10. Create databases and run migrations
`bin/rake db:create`
`bin/rake db:create RAILS_ENV=test`
`bin/rake db:migrate`
Expand Down
7 changes: 0 additions & 7 deletions app/models/util/db_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,17 @@ def initialize(params={})
# of all load events that have occurred. If an event is passed in, use it; otherwise, create a new one.
@event = params[:event]
@fm = Util::FileManager.new
@config = YAML.safe_load(File.read("#{Rails.root}/config/connections.yml")).deep_symbolize_keys
end

##### connection management #####

def public_connection
db = @config[:public]
return unless db

connection = PublicBase.establish_connection(db).connection
connection.schema_search_path = 'ctgov'
connection
end

def staging_connection
db = @config[:staging]
return unless db

connection = PublicBase.establish_connection(db).connection
connection.schema_search_path = 'ctgov'
connection
Expand Down

0 comments on commit 7ea2e69

Please sign in to comment.