major-domo-database/test_migration_workflow.sh
Cal Corum 79a559088a CLAUDE: Phase 1 PostgreSQL migration fixes complete
- Fixed 4 critical schema issues blocking migration
- Resolved integer overflow by converting Discord IDs to strings
- Fixed VARCHAR length limits for Google Photos URLs
- Made injury_count field nullable for NULL values
- Successfully migrating 7/30 tables (5,432+ records)

Issues resolved:
- CONSTRAINT-CURRENT-INJURY_COUNT-001: Made nullable
- DATA_QUALITY-PLAYER-NAME-001: Increased VARCHAR limits to 1000
- MIGRATION_LOGIC-TEAM-INTEGER-001: Discord IDs now strings
- MIGRATION_LOGIC-DRAFTDATA-INTEGER-001: Channel IDs now strings

New issues discovered for Phase 2:
- CONSTRAINT-CURRENT-BSTATCOUNT-001: NULL stats count
- CONSTRAINT-TEAM-AUTO_DRAFT-001: NULL auto draft flag

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 18:09:45 -05:00

111 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
# Test Migration Workflow Script
# Automates the complete migration testing process
set -e # Exit on any error
echo "=========================================="
echo "🧪 POSTGRESQL MIGRATION TESTING WORKFLOW"
echo "=========================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
print_step() {
echo -e "\n${BLUE}📋 Step $1: $2${NC}"
}
print_success() {
echo -e "${GREEN}$1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_error() {
echo -e "${RED}$1${NC}"
}
# Check if Docker containers are running
print_step 1 "Checking Docker containers"
if docker ps | grep -q "sba_postgres"; then
print_success "PostgreSQL container is running"
else
print_error "PostgreSQL container not found - run: docker-compose up postgres -d"
exit 1
fi
if docker ps | grep -q "sba_adminer"; then
print_success "Adminer container is running"
else
print_warning "Adminer container not running - run: docker-compose up adminer -d"
fi
# Test PostgreSQL connectivity
print_step 2 "Testing PostgreSQL connectivity"
if python test_postgres.py > /dev/null 2>&1; then
print_success "PostgreSQL connection test passed"
else
print_error "PostgreSQL connection test failed"
echo "Run: python test_postgres.py for details"
exit 1
fi
# Reset PostgreSQL database
print_step 3 "Resetting PostgreSQL database"
if python reset_postgres.py > /dev/null 2>&1; then
print_success "PostgreSQL database reset complete"
else
print_error "Database reset failed"
echo "Run: python reset_postgres.py for details"
exit 1
fi
# Check SQLite source data
print_step 4 "Checking SQLite source data"
if [ -f "storage/sba_master.db" ]; then
SIZE=$(du -h storage/sba_master.db | cut -f1)
print_success "SQLite database found (${SIZE})"
else
print_error "SQLite database not found at storage/sba_master.db"
exit 1
fi
# Run migration
print_step 5 "Running data migration"
echo "This may take several minutes depending on data size..."
if python migrate_to_postgres.py; then
print_success "Migration completed successfully"
else
print_error "Migration failed"
exit 1
fi
# Validate migration
print_step 6 "Validating migration results"
if python validate_migration.py; then
print_success "Migration validation passed"
else
print_error "Migration validation failed"
exit 1
fi
# Final summary
echo -e "\n=========================================="
echo -e "${GREEN}🎉 MIGRATION TEST COMPLETE${NC}"
echo "=========================================="
echo -e "📊 View data in Adminer: ${BLUE}http://localhost:8080${NC}"
echo " Server: postgres"
echo " Username: sba_admin"
echo " Password: sba_dev_password_2024"
echo " Database: sba_master"
echo ""
echo -e "🔄 To test again: ${YELLOW}./test_migration_workflow.sh${NC}"
echo -e "🗑️ To reset only: ${YELLOW}python reset_postgres.py${NC}"
echo "=========================================="