Documentation: How to reset the database for local development
- Dominant language
- Python
- Stars
- 4
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
This assumes the developers has a working UMIL directory, but has some issues with the out-of-sync database. I did this when helping @yinanazhou update her one-year-old UMIL database. `docker ... prune` doesn't work because the database is stored in a file and not related to the docker container/image, and it's more difficult to find where the database file is located (even with `docker inspect`).
---
0. How to know if the existing database is not empty: do `docker logs vim-db` with the service up and running. If the result is shown as below, the database is not empty!
```sh
$ docker logs vim-db
PostgreSQL Database directory appears to contain a database; Skipping initialization
...
```
Optionally, one can access the database to check for existing tables. Replace `username` field below with your username from `.env`. Once you are in the PostgreSQL, `\dt` can show you all tables in the database.
```sh
$ docker exec -it vim-db psql -U username -d virtual_instrument_museum
virtual_instrument_museum=# \dt
```
---
1. Making sure all UMIL services are offline. `vim-solr` and `vim-app` are the "active users" of
```sh
docker compose down
```
2. Turn on only `vim-db`
```sh
docker compose up postgres -d # make it run on the background
```
3. Access the postgreSQL shell with. Replace `username` field below with your username in `.env`
```sh
docker exec -it vim-db psql -U username -d postgres
```
4. You are now in psql shell. To view all existing database, do `\l`. If you can see `virtual_instrument_museum`, you're on the right track! To drop (delete) and recreate the database, you can: (don't forget the end-of-line semicolon `;`)
```psql
DROP DATABASE virtual_instrument_museum;
CREATE DATABASE virtual_instrument_museum;
```
5. Now that you have a fresh empty database, go back to the setup instructions and migrate. Make sure you turn on all other services too.
```sh
docker compose up
```
https://github.com/DDMAL/VIM/blob/a15a3e8b512adeee6c7b9f62817a6ad0afe73a74/README.md?plain=1#L30-L38
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked README.md setup section and review the referenced .env values and Docker Compose service names. Verify the documented commands against the local development setup, then add the reset procedure and confirm that a newcomer can identify and recreate a stale PostgreSQL database.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, postgresql
- Domain
- databases, devops, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100