-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema_change.sh
executable file
·79 lines (64 loc) · 2.03 KB
/
schema_change.sh
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
#!/bin/bash
#
# AdaptiveScale Inc.
#
echo "#####################"
echo "# #"
echo "# Starting Script #"
echo "# #"
echo "#####################"
# Determine the OS and Architecture
OS=$(uname -s)
ARCH=$(uname -m)
# Set URL, ZIP_FILE, and EXTRACTION_DIR based on OS and ARCH
if [[ "$OS" == "Darwin" ]]; then
if [[ "$ARCH" == "arm64" ]]; then
echo "Running on macOS (ARM architecture)"
export PATH=$PATH:rosetta/mac_aarch64/bin
elif [[ "$ARCH" == "x86_64" ]]; then
echo "Running on macOS (Intel architecture)"
export PATH=$PATH:rosetta/mac_x64/bin
else
echo "Unknown architecture on macOS: $ARCH"
exit 1
fi
elif [[ "$OS" == "Linux" ]]; then
echo "Running on Linux"
if [[ "$ARCH" == "x86_64" ]]; then
export PATH=$PATH:rosetta/linux_x64/bin
elif [[ "$ARCH" == "arm64" ]]; then
echo "Not supported Linux arm64"
else
echo "Unknown architecture on Linux: $ARCH"
exit 1
fi
else
echo "Unsupported OS: $OS"
exit 1
fi
# Set environment variables
export ROSETTA_DRIVERS=$(pwd)/drivers
export EXTERNAL_TRANSLATION_FILE=translation/translation.csv
# Function to calculate total execution time
function calculate_execution_time {
end_time=$(date +%s)
execution_time=$((end_time - start_time))
hours=$((execution_time / 3600))
minutes=$(( (execution_time % 3600) / 60 ))
seconds=$((execution_time % 60))
printf "MySQL to Postgres changes migration script total execution time: %02d:%02d:%02d\n" $hours $minutes $seconds
}
# Start time
start_time=$(date +%s)
#Step 1: Schema Migration
echo "[DEBUG] ROSETTA_DRIVERS=$ROSETTA_DRIVERS"
echo "[DEBUG] PATH=$PATH"
echo "[DEBUG] EXTERNAL_TRANSLATION_FILE=$EXTERNAL_TRANSLATION_FILE"
echo "[DEBUG] Show rosetta version"
rosetta --version
echo "[DEBUG] Migrate schema: MySQL to Postgres"
rosetta extract -s mysql -t postgres
rosetta compile -s mysql -t postgres
echo "[DEBUG] Applying changes to Postgres"
rosetta apply -s postgres
calculate_execution_time