bazzar/scripts/migrate.sh

20 lines
803 B
Bash
Executable File

#!/usr/bin/env zsh
source .env
if [[ "$1" == "purge" ]];
then
psql postgres postgres -c "DROP DATABASE ${DATABASE_NAME}_accounts" || echo 0
psql postgres postgres -c "DROP DATABASE ${DATABASE_NAME}_carts" || echo 0
psql postgres postgres -c "DROP DATABASE ${DATABASE_NAME}_stocks" || echo 0
fi
psql postgres postgres -c "CREATE DATABASE ${DATABASE_NAME}_accounts" || echo 0
sqlx migrate run -D "${ACCOUNT_DATABASE_URL}" --source ./crates/account_manager/migrations
psql postgres postgres -c "CREATE DATABASE ${DATABASE_NAME}_carts" || echo 0
sqlx migrate run -D "${CART_DATABASE_URL}" --source ./crates/cart_manager/migrations
psql postgres postgres -c "CREATE DATABASE ${DATABASE_NAME}_stocks" || echo 0
sqlx migrate run -D "${STOCK_DATABASE_URL}" --source ./crates/stock_manager/migrations