xonecas.io
53129
Pa

PAT / files

PAT / scripts / wipe-dev-db.sh

934 bytes
1#!/usr/bin/env bash
2set -euo pipefail
3
4echo "⚠️  WARNING: This will delete the PostgreSQL container and ALL database data!"
5
6# Stop and delete PostgreSQL container if it exists
7if docker ps -a --format '{{.Names}}' | grep -q '^postgres$'; then
8  echo "Stopping PostgreSQL container..."
9  docker stop postgres 2>/dev/null || true
10  echo "PostgreSQL container stopped."
11  
12  echo "Removing PostgreSQL container..."
13  docker rm postgres 2>/dev/null || true
14  echo "PostgreSQL container removed."
15else
16  echo "PostgreSQL container not found."
17fi
18
19# Remove the volume to completely wipe all data
20if docker volume ls --format '{{.Name}}' | grep -q '^postgres_data$'; then
21  echo "Removing postgres_data volume..."
22  docker volume rm postgres_data
23  echo "✓ Volume removed. All database data has been wiped."
24else
25  echo "postgres_data volume not found."
26fi
27
28echo ""
29echo "✅ PostgreSQL container and all data removed successfully!"
30