-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·135 lines (122 loc) · 3.75 KB
/
start.sh
File metadata and controls
executable file
·135 lines (122 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# MySQL to PostgreSQL Migration Tool - Development Quick Start
# This script provides an easy way to get started with development
set -e
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Print banner
echo -e "${GREEN}"
echo "==============================================="
echo " MySQL to PostgreSQL Migration Tool"
echo " Development Setup"
echo "==============================================="
echo -e "${NC}"
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo -e "${RED}Error: Docker is not installed. Please install Docker first.${NC}"
exit 1
fi
if ! command -v docker-compose &> /dev/null; then
echo -e "${RED}Error: Docker Compose is not installed. Please install Docker Compose first.${NC}"
exit 1
fi
# Function to display options
show_menu() {
echo -e "${YELLOW}What would you like to do?${NC}"
echo "1) Quick Start (setup + test + migrate)"
echo "2) Setup environment only"
echo "3) Run test migration (dry-run)"
echo "4) Run actual migration"
echo "5) Run validation"
echo "6) View logs"
echo "7) Open development shell"
echo "8) Clean and reset environment"
echo "9) Stop all services"
echo "0) Exit"
echo ""
read -p "Enter your choice [0-9]: " choice
}
# Function to wait for services
wait_for_services() {
echo -e "${YELLOW}Waiting for database services to be ready...${NC}"
sleep 15
# Check if services are healthy
if docker-compose exec mysql mysqladmin ping -h localhost --silent; then
echo -e "${GREEN}✅ MySQL is ready${NC}"
else
echo -e "${RED}❌ MySQL is not ready${NC}"
return 1
fi
if docker-compose exec postgres pg_isready -U testuser -d test_target >/dev/null 2>&1; then
echo -e "${GREEN}✅ PostgreSQL is ready${NC}"
else
echo -e "${RED}❌ PostgreSQL is not ready${NC}"
return 1
fi
}
# Main menu loop
while true; do
show_menu
case $choice in
1)
echo -e "${GREEN}Starting quick setup...${NC}"
make docker-up
wait_for_services
echo -e "${GREEN}Running test migration...${NC}"
make docker-test
echo -e "${GREEN}Running actual migration...${NC}"
make docker-migrate
echo -e "${GREEN}Running validation...${NC}"
make docker-validate
echo -e "${GREEN}✅ Quick start completed!${NC}"
;;
2)
echo -e "${GREEN}Setting up environment...${NC}"
make docker-up
wait_for_services
echo -e "${GREEN}✅ Environment ready!${NC}"
;;
3)
echo -e "${GREEN}Running test migration...${NC}"
make docker-test
;;
4)
echo -e "${GREEN}Running actual migration...${NC}"
make docker-migrate
;;
5)
echo -e "${GREEN}Running validation...${NC}"
make docker-validate
;;
6)
echo -e "${GREEN}Showing logs...${NC}"
make docker-logs
;;
7)
echo -e "${GREEN}Opening development shell...${NC}"
make docker-dev-shell
;;
8)
echo -e "${GREEN}Cleaning and resetting environment...${NC}"
make docker-reset
;;
9)
echo -e "${GREEN}Stopping all services...${NC}"
make docker-down
;;
0)
echo -e "${GREEN}Goodbye!${NC}"
exit 0
;;
*)
echo -e "${RED}Invalid option. Please try again.${NC}"
;;
esac
echo ""
echo -e "${YELLOW}Press Enter to continue...${NC}"
read
clear
done