Skip to content

Commit

Permalink
Added a script to reset the db (#80)
Browse files Browse the repository at this point in the history
Co-authored-by: Nargis Sultani <[email protected]>
  • Loading branch information
nargis-sultani and Nargis Sultani authored Jan 3, 2024
1 parent 219a8ae commit bf8d7c5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
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

0 comments on commit bf8d7c5

Please sign in to comment.