You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51-46Lines changed: 51 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,53 +38,45 @@ You can find information about the ClinicalTrials.gov beta API here: https://cli
38
38
39
39
## Getting Started
40
40
41
-
1. Install PostgreSQL 13.
41
+
1. Install PostgreSQL 13. If you have a Mac you can use brew to install PostgreSQL.
42
+
`brew install postgresql`
43
+
42
44
Here are some links that could help you setup
43
45
https://www.postgresql.org/download/linux/ubuntu/
44
46
https://www.postgresql.org/download/macosx/
45
47
Note: do not delete the template databases, meaning template0 and template1. They are what PostgreSQL uses to create all other databases. If you remove them you will no longer be able to make new databases.
46
48
47
-
2. Now we will focus on the “.pgpass” file for storing your connection info. Here is a document about the “.pgpass” file
The “.pgpass” should be at your root. You can edit it using Vim or your preferred editor that lets you edit from the terminal. I will explain editing it using Vim commands.
50
-
`vim ~/.pgpass` this directs vim to open the file you want to edit. It will create that file if it does not already exist.
51
-
`i` this triggers insert mode (it will say insert at the bottom) so you can edit the file.
52
-
Add “hostname:port:database:username:password” to the file but fill in the words with your info.
53
-
Example: `localhost:5432:*:postgres:pg_password`
54
-
Press the `esc` button to leave insert mode.
55
-
`:xa` will save and close the file.
49
+
2. Now we will create the roles you need for running AACT.
50
+
`psql postgres` this allows you to enter the postgres database that comes with PostgreSQL.
51
+
`postgres=# create role <your_aact_superuser> login password '<your_superuser_password>’;`
52
+
`postgres=# alter user <your_aact_superuser> with superuser;`
53
+
`postgres=# create role read_only;`
54
+
`postgres=# create database aact_alt;`
55
+
`postgres=# \q` this exits out of psql
56
+
Verify your new user can login to psql with command: `psql -U <your_aact_superuser> -d postgres`
57
+
You can exit the shell once you see you can log in.
58
+
59
+
3. If your terminal asks for a password when logging in to psql you can give it the password automatically by adding it to the “.pgpass” file. If you haven’t been asked for a password, you can skip this step.
Now check that you can login to psql without giving a password
57
-
`psql -U postgres -d template1`
58
-
Look here for more Vim commands https://www.linux.com/training-tutorials/vim-101-beginners-guide-vim/
59
-
60
-
3. Now we will create the roles you need for running AACT.
61
-
`psql -U postgres -d template1` this allows you to enter the template1 database that comes with PostgreSQL.
62
-
`template1=# create role <your_aact_superuser> login password '<your_superuser_password>’;`
63
-
`template1=# alter user <your_aact_superuser> with superuser;`
64
-
`template1=# create role read_only;`
65
-
`template1=# \q` this exits out of psql
66
-
Verify your new user can login to psql with command: `psql -U <your_aact_superuser> -d template1`
67
-
You can exit the shell once you see you can log in.
68
-
69
-
4. Now we want to store the environmental variables for the superuser that you created in the previous step. That is the user you will be using within AACT to make database changes.
70
-
`vim ~/.bash_profile` You can switch out bash_profile for your usual file for storing environmental variables, such as an zshrc file.
71
-
`i` Enter insert mode and add the following to the file
By default, AACT saves files it creates in a directory under /aact-files. (Note, this is in the server root directory, not the root of the AACT application.) To override this, use the AACT_STATIC_FILE_DIR environment variable to define a different directory. Otherwise, you will need to create /aact-files at the server root directory and change permissions on it so that the rails application owner has permission to read/write to that directory.
76
-
`export AACT_STATIC_FILE_DIR=public/static`*we are working towards removing the need to add this variable*
77
-
<br>
78
-
The pg gem (used by AACT) will need to know where to find your PostgreSQL installation. For Mac you can direct it to that location by adding
79
-
`export PATH=$PATH:/Library/PostgreSQL/x.y/bin`*change x.y to the version number of your PostgreSQL installation, like: `export PATH=$PATH:/Library/PostgreSQL/13/bin`*
Press the `esc` button to leave insert mode, then `:xa` to save and close the file.
83
-
<br>
84
-
`source ~/.bash_profile` refreshes/establishes the terminals connection to the file so it will pick up the variables you added.
85
-
*Note: you will need to use the source command whenever you edit the “.bash_profile” or open a new terminal.*
86
-
<br>
87
-
You can add `your_aact_superuser` to the “.pgpass” file to save yourself having to type the password when logging into the shell. Add `hostname:port:database:<superuser_name>:<superuser_password>` to your pgpass file. If you aren’t sure how to do it follow the guidance in step 2.
63
+
`psql -U aact_pg_user -d postgres`
64
+
You can exit the shell once you see you can log in without a password.
65
+
66
+
Here is a document about the “.pgpass” file https://www.postgresql.org/docs/current/libpq-pgpass.html.
67
+
68
+
4. Now we want to store the environmental variables for the superuser that you created in the previous step. That is the user you will be using within AACT to make database changes. You can store these wherever is appropriate for your system. On a Mac you can store it in your “.zshrc”. On all systems you can also store it in your “.bash_profile” or “.bashrc”.
69
+
For the following commands I’m storing variables in the “.zshrc” file, change out that file in the commands for the one you use for storing variables.
`source ~/.zshrc` to load the variables into the terminal session.
78
+
79
+
Depending on where you store the variables you may need to call `source` on that file each time you open a new terminal. This is not necessary for “.zshrc”.
88
80
89
81
5. Clone this repo: `git clone git@github.com:ctti-clinicaltrials/aact.git`
90
82
Note: Cloning with a ssh url requires that your local ssh key is saved to Github. The key verifies your permission to push and pull so you won't have to log in. If you haven't saved your ssh key to Github use the html url instead when cloning.
@@ -94,6 +86,11 @@ You can find information about the ClinicalTrials.gov beta API here: https://cli
94
86
7. Install a ruby version manager like rbenv, then install Ruby 2.6.2
95
87
96
88
8. Bundle install
89
+
The pg gem (used by AACT) may have trouble finding your PostgreSQL installation. If not, skip this step.
90
+
For Mac you can direct it to the right location location by adding
91
+
`echo ‘export PATH=$PATH:/Library/PostgreSQL/x.y/bin’ >> ~/.zshrc` change x.y to the version number of your PostgreSQL installation.
9. Use the "connections.yml.example" file and copy it to the file "connnections.yml" and just update what needs to be updated for the local environment.
99
96
In the terminal, type `cp connections.yml.example connections.yml`.
@@ -105,6 +102,10 @@ You can find information about the ClinicalTrials.gov beta API here: https://cli
105
102
`bin/rake db:migrate`
106
103
`bin/rake db:migrate RAILS_ENV=test`
107
104
105
+
11. Grant read_only privileges
106
+
`bin/rake grant:db_privs:run`
107
+
`bin/rake grant:db_privs:run RAILS_ENV=test`
108
+
108
109
<br>
109
110
<br>
110
111
@@ -115,12 +116,16 @@ You can find information about the ClinicalTrials.gov beta API here: https://cli
115
116
## Populating the Database
116
117
117
118
The seed files are out of date so **DO NOT** call `db:seed`. Instead use the custom rake tasks.
118
-
These are your options:
119
-
*`bin/rake db:restore_from_file[<path_to_file>,<database_name>]`*this method is currently not working*
120
-
For this option go to https://aact.ctti-clinicaltrials.org/snapshots and download a copy of the database. Give this task the path to the file you downloaded and it will upzip it before using it to populate the database.
For this option go to https://aact.ctti-clinicaltrials.org/snapshots and copy the link for one of the database copies. Give this task the url you copied and it will download the file, upzip it, and use it to populate the database.
123
-
*Note: the following rake tasks take a very long time to run*
127
+
For this option go to https://aact.ctti-clinicaltrials.org/snapshots and copy the link for one of the database copies. Give this task the url you copied and it will download the file, unzip it, and use it to populate the database.
128
+
*Note: the rake tasks below take a very long time to run. You should not set full_featured to true if working locally.*
The days back is an integer, the event_type only takes "full" or "incremental", full_featured is a boolean. You do not have to give it any parameters. If you have no studies it will populate your database with all the studies.
0 commit comments