mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-19 21:55:03 +01:00
* Add PostgreSQL support for mint and wallet * Fixed bug to avoid empty calls `get_proofs_states` * Fixed SQL bug * Avoid redudant clone() * Add more tests for the storage layer * Minor enhacements * Add a generic function to execute db operations This function would log slow operations and log errors * Provision a postgres db for tests * Update deps for msrv * Add postgres to pipeline * feat: add psgl to example and docker * feat: db url fmt --------- Co-authored-by: thesimplekid <tsk@thesimplekid.com>
31 lines
984 B
Bash
31 lines
984 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
CONTAINER_NAME="rust-test-pg"
|
|
DB_USER="test"
|
|
DB_PASS="test"
|
|
DB_NAME="testdb"
|
|
DB_PORT="5433"
|
|
|
|
echo "Starting fresh PostgreSQL container..."
|
|
docker run -d --rm \
|
|
--name "${CONTAINER_NAME}" \
|
|
-e POSTGRES_USER="${DB_USER}" \
|
|
-e POSTGRES_PASSWORD="${DB_PASS}" \
|
|
-e POSTGRES_DB="${DB_NAME}" \
|
|
-p ${DB_PORT}:5432 \
|
|
postgres:16
|
|
|
|
echo "Waiting for PostgreSQL to be ready and database '${DB_NAME}' to exist..."
|
|
until docker exec -e PGPASSWORD="${DB_PASS}" "${CONTAINER_NAME}" \
|
|
psql -U "${DB_USER}" -d "${DB_NAME}" -c "SELECT 1;" >/dev/null 2>&1; do
|
|
sleep 0.5
|
|
done
|
|
|
|
docker exec -e PGPASSWORD="${DB_PASS}" "${CONTAINER_NAME}" \
|
|
psql -U "${DB_USER}" -d "${DB_NAME}" -c "CREATE DATABASE mintdb;"
|
|
docker exec -e PGPASSWORD="${DB_PASS}" "${CONTAINER_NAME}" \
|
|
psql -U "${DB_USER}" -d "${DB_NAME}" -c "CREATE DATABASE mintdb_auth;"
|
|
|
|
export DATABASE_URL="host=localhost user=${DB_USER} password=${DB_PASS} dbname=${DB_NAME} port=${DB_PORT}"
|