Justfile targets for db-backup, db-restore, pgshell and re-migrate for debugging
This commit is contained in:
parent
a5dadfc1d1
commit
a2064b440d
1 changed files with 18 additions and 0 deletions
18
justfile
18
justfile
|
@ -55,6 +55,24 @@ start-postgres-dev: create-network
|
|||
podman rm -f {{pg_container}}
|
||||
podman run --network {{network}} --name {{pg_container}} -e POSTGRES_PASSWORD={{pg_pass}} -d -p {{pg_port}}:5432 docker.io/postgres:16.1-alpine
|
||||
|
||||
pgshell:
|
||||
podman exec -it {{pg_container}} psql -U {{pg_user}} -d {{db_name}}
|
||||
|
||||
re-migrate:
|
||||
echo {{env_local}} > server/.env
|
||||
cd server && cargo sqlx database drop -y
|
||||
cd server && cargo sqlx database create
|
||||
cd server && cargo sqlx migrate run
|
||||
@echo "Database re-initialized and migrations re-run."
|
||||
|
||||
db-backup:
|
||||
podman exec -t {{pg_container}} pg_dump -U {{pg_user}} -d {{db_name}} | gzip > frostbyte_backup$(date +'%Y-%m-%d_%H:%M:%S').sql.gz
|
||||
|
||||
# Drops the database and restores it from a backup file
|
||||
db-restore backupfile: db-backup
|
||||
podman exec -i {{pg_container}} psql -U {{pg_user}} -d {{db_name}} -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
|
||||
gunzip -c {{backupfile}} | podman exec -i {{pg_container}} psql -U {{pg_user}} -d {{db_name}}
|
||||
|
||||
[private]
|
||||
create-network:
|
||||
podman network create {{network}} --ignore
|
||||
|
|
Loading…
Reference in a new issue