Skip to content

Commit

Permalink
Merge pull request #114 from NIAEFEUP/chore/db-clean-script
Browse files Browse the repository at this point in the history
add: makefile command to populate db
  • Loading branch information
tomaspalma authored Oct 6, 2024
2 parents 8211d5a + 691bd99 commit fec3fcb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ upload:
@echo [UPLOADING] data...
@docker-compose run fetcher python ./update_data/upload.py

populate:
@-docker compose down
@-docker compose build --no-cache
@-docker volume rm tts_postgres_data || true
@-docker compose up

clean: clean_fetcher clean_database

clean_fetcher:
Expand Down
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ https://drive.google.com/drive/folders/1hyiwPwwPWhbAPeJm03c0MAo1HTF6s_zK?usp=sha

- Copy the ```01_data.sql``` and ```00_schema_postgres.sql``` of year and semester you desire to the ```postgres/sql``` folder.

Then you can run

```bash
make populate
```

This will down the container, clearing the data from the database and then build and running the container again. This can be both used for people who are first running the project as well as for people that have already run the project but want to insert a new sql data file.

## Usage

### Development environment
Expand All @@ -35,17 +43,6 @@ After you installed docker, go to the folder where you cloned this repository an
```yaml
docker compose build
```

This will build the docker container for the backend.

In case you have __already build the server before and want to repopulate the database__, make sure you run

```bash
sudo make clean
```

We need to clean the database to repopulate it, since the way the postgres container works is that it only runs the `sql` files present in the `postgres/sql` folder if the database is clean. This is way we need to issue `sudo make clean` in order for the insert sql queries to be run.

#### Running the container

Before running docker, you have to create an `.env` file with required environment variables for the backend to work.
Expand Down

0 comments on commit fec3fcb

Please sign in to comment.