|
| 1 | +# VA Online Memorial Database Set Up |
| 2 | + |
| 3 | +The data dump you will need to use to set up the database is in the Rest API Repo: https://github.com/topcoderinc/va-online-memorial-rest-api/docs/vaonline.sqlc |
| 4 | + |
| 5 | +You will also need the frontend repo: https://github.com/topcoderinc/va-online-memorial-frontend |
| 6 | + |
| 7 | +And PostgreSQL: download at postgresql.org or `$ brew install postgres` |
| 8 | + |
| 9 | +Pop open your terminal if you didn’t already for Homebrew |
| 10 | +Create database with the command: `$ psql vaonline -U username`. The database name should be ‘vaonline’. Remember your username and password! You will need those later! |
| 11 | +`$ cd` to where the data dump is |
| 12 | +Run `$ pg_restore -U postgres --dbname=vaonline -c vaonline.sqlc` |
| 13 | + |
| 14 | +You should see: |
| 15 | +```pg_restore: [archiver (db)] Error from TOC entry 3373; 0 0 ACL public aws_broker |
| 16 | +pg_restore: [archiver (db)] could not execute query: ERROR: role "aws_broker" does not exist |
| 17 | + Command was: REVOKE ALL ON SCHEMA public FROM PUBLIC; |
| 18 | +REVOKE ALL ON SCHEMA public FROM aws_broker; |
| 19 | +GRANT ALL ON SCHEMA public TO aws_broker; |
| 20 | +GRANT ALL ON SCHEMA public TO PUBLIC; |
| 21 | +
|
| 22 | +WARNING: errors ignored on restore: 66 |
| 23 | +``` |
| 24 | + |
| 25 | + |
| 26 | +Open your database: `$ psql vaonline` |
| 27 | + |
| 28 | +You should see ‘vaonline=#’ |
| 29 | +Run `$ \d+ *` |
| 30 | +You should see something similar to: |
| 31 | +``` |
| 32 | +List of relations |
| 33 | + Schema | Name | Type | Owner | Size | Description |
| 34 | +--------+--------------------------------+----------+-------+------------+------------- |
| 35 | + public | BadgeTypes | table | user | 8192 bytes | |
| 36 | + public | BadgeTypes_id_seq | sequence | user | 8192 bytes | |
| 37 | + public | Badges | table | user | 0 bytes | |
| 38 | + public | Badges_id_seq | sequence | user | 8192 bytes | |
| 39 | + public | Branches | table | user | 8192 bytes | |
| 40 | +… |
| 41 | +``` |
| 42 | + |
| 43 | +And you have a database! Any time you come back to work on the Online Memorial, make sure PostgrSQL is running. |
| 44 | + |
| 45 | +From here, you can skip to the ‘[3]REST API Module’ section of the VA Online Memorial Deployment Guide V2 in the Frontend Repo. |
| 46 | + |
| 47 | +## Troubleshooting: |
| 48 | +It is recommended that after you import the database, you use a service like [Postico](https://eggerapps.at/postico/) to view the tables and ensure the database imported correctly. |
| 49 | + |
| 50 | +Go to the ‘Veterans’ table. |
| 51 | + |
| 52 | +If you see a single entry (first name:ffff middle name: mmmm last name: llll), you need to complete the following steps: |
| 53 | + |
| 54 | +Select all the tables (don't worry about the folders at the bottom) |
| 55 | +Right click > delete, select the checkbox for ‘cascade’, follow the prompts. |
| 56 | + |
| 57 | +Go back to terminal and re-run: `$ pg_restore -U postgres --dbname=vaonline -c vaonline.sqlc` |
| 58 | + |
| 59 | +Go back to Postico and hit the refresh botton (top right-side) |
| 60 | + |
| 61 | +You should have a bunch of Veteran’s names! Tah-dah! |
0 commit comments