#!/bin/bash # ============================================ # Cleanup Orphaned Mission Calendars Script # ============================================ # This script helps clean up calendars from deleted missions # # Usage: # ./scripts/cleanup-orphaned-mission-calendars.sh [--dry-run] [--execute] # # Options: # --dry-run : Show what would be deleted (default) # --execute : Actually delete the orphaned calendars set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color DRY_RUN=true EXECUTE=false # Parse arguments while [[ $# -gt 0 ]]; do case $1 in --execute) EXECUTE=true DRY_RUN=false shift ;; --dry-run) DRY_RUN=true EXECUTE=false shift ;; *) echo "Unknown option: $1" echo "Usage: $0 [--dry-run] [--execute]" exit 1 ;; esac done echo -e "${YELLOW}========================================${NC}" echo -e "${YELLOW}Cleanup Orphaned Mission Calendars${NC}" echo -e "${YELLOW}========================================${NC}" echo "" # Check if docker-compose is available if ! command -v docker-compose &> /dev/null; then echo -e "${RED}Error: docker-compose not found${NC}" exit 1 fi # Check if .env.production exists if [ ! -f ".env.production" ]; then echo -e "${RED}Error: .env.production file not found${NC}" exit 1 fi if [ "$DRY_RUN" = true ]; then echo -e "${YELLOW}Mode: DRY RUN (no changes will be made)${NC}" echo "" echo "Reviewing orphaned calendars..." echo "" docker-compose -f docker-compose.prod.yml --env-file .env.production exec -T db psql -U neah_user -d calendar_db <