Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a script to reset the db #80

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ $ docker compose up -d pg keycloak
```
![Docker](images/sbl_project_svcs.png)

---
## Resetting DB and Seeding mock data
On app startup, alembic creates all the tables and seeds the lookup tables.
Running the below script with the 'reset' argument will reset the db:
db_revisions/dev_setup.sh reset
Passing the 'reset-then-seed' argument to the script will reset the db and then seed the lookup tables:
db_revisions/dev_setup.sh reset-then-seed

---
## Running the app
Once the [Dependencies](#dependencies), and [Pre-requisites](#pre-requisites) have been satisfied:
Expand Down
22 changes: 22 additions & 0 deletions db_revisions/dev_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

if [[ $1 == "" ]]
then
echo "No arguments passed!"
echo "The argument must be either reset or reset-then-seed"
exit 0
fi

ACTION=$1

if [ $ACTION == "reset" ]
then
#If only need to reset db
poetry run alembic downgrade base
elif [ $ACTION == "reset-then-seed" ]
then
#First reset the db
poetry run alembic downgrade base
#Then upgrade it to head
poetry run alembic upgrade head
fi
Loading