bazzar/scripts/migrate.sh

20 lines
803 B
Bash
Raw Normal View History

2022-11-04 18:40:14 +01:00
#!/usr/bin/env zsh
source .env
2022-11-11 16:32:07 +01:00
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
2022-11-05 10:57:07 +01:00
psql postgres postgres -c "CREATE DATABASE ${DATABASE_NAME}_accounts" || echo 0
2022-11-04 18:40:14 +01:00
sqlx migrate run -D "${ACCOUNT_DATABASE_URL}" --source ./crates/account_manager/migrations
2022-11-05 10:57:07 +01:00
psql postgres postgres -c "CREATE DATABASE ${DATABASE_NAME}_carts" || echo 0
2022-11-04 18:40:14 +01:00
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