28 lines
1.3 KiB
Bash
Executable File
28 lines
1.3 KiB
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
|
|
psql postgres postgres -c "DROP DATABASE ${DATABASE_NAME}_orders" || echo 0
|
|
psql postgres postgres -c "DROP DATABASE ${DATABASE_NAME}_tokens" || 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
|
|
|
|
psql postgres postgres -c "CREATE DATABASE ${DATABASE_NAME}_orders" || echo 0
|
|
sqlx migrate run -D "${ORDER_DATABASE_URL}" --source ./crates/order_manager/migrations
|
|
|
|
psql postgres postgres -c "CREATE DATABASE ${DATABASE_NAME}_tokens" || echo 0
|
|
sqlx migrate run -D "${TOKEN_DATABASE_URL}" --source ./crates/token_manager/migrations
|