# This is a justfile, see also https://github.com/casey/just.
# Load environment variables from the .env file.
set dotenv-load
# Lists available recipes.
default:
just --list
# Starts the containers in the docker-compose.yml file used during development.
up *args:
docker compose up --wait --remove-orphans {{ args }}
# Stops the development containers.
down *args:
docker compose down {{ args }}
# Connect to the development PostgreSQL database.
@psql:
docker compose exec -it postgres psql $DATABASE_URL
# Dumps the database schema as it appears after all migrations. This file is not used for anything; it is purely used as a convenient reference for developers to understand the structure of the database. It is more convenient to read than going through all the migrations.
@generate_schema:
# Dumps the schema and removes comment lines and strips consecutive blank lines to get it cleaner.
docker compose exec postgres pg_dump --schema-only $DATABASE_URL | sed -e '/^--/d' -e '/./,/^$/!d' | sed "1i\-- This is the schema of Yarn\'s database.\n-- This is purely provided for convenient perusal, not actually used for anything.\n-- The migrations in the migrations folder are what actually defines the database.\n-- Use \`just generate_schema\` to regenerate this file.\n" > schema.sql
# Drops the development database, then run all migrations.
db_reset: && generate_schema
sqlx database reset --connect-timeout 1 --force -y
# Prepares query data for offline query validation by SQLX.
@db_prepare:
cargo sqlx prepare --connect-timeout 1 -- --tests