bazzar/scripts/migrate.sh

28 lines
1.3 KiB
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
2022-11-29 15:18:31 +01:00
psql postgres postgres -c "DROP DATABASE ${DATABASE_NAME}_orders" || echo 0
2022-12-20 15:34:20 +01:00
psql postgres postgres -c "DROP DATABASE ${DATABASE_NAME}_tokens" || echo 0
2022-11-11 16:32:07 +01:00
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
2022-11-29 15:18:31 +01:00
psql postgres postgres -c "CREATE DATABASE ${DATABASE_NAME}_orders" || echo 0
sqlx migrate run -D "${ORDER_DATABASE_URL}" --source ./crates/order_manager/migrations
2022-12-20 15:34:20 +01:00
psql postgres postgres -c "CREATE DATABASE ${DATABASE_NAME}_tokens" || echo 0
sqlx migrate run -D "${TOKEN_DATABASE_URL}" --source ./crates/token_manager/migrations