diff --git a/README.md b/README.md index 307dbc6..00bd9c3 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/db_revisions/dev_setup.sh b/db_revisions/dev_setup.sh new file mode 100755 index 0000000..87fcd05 --- /dev/null +++ b/db_revisions/dev_setup.sh @@ -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 \ No newline at end of file