Skip to content
Snippets Groups Projects
Commit 3e3f9bcc authored by YuJin's avatar YuJin
Browse files

Merge branch 'main' into 'main'

feat: Add SportType SQL insert statements for initial data

See merge request !33
parents d6bf7cc5 2c34b764
Branches
Tags Audacity-2.2.1-rc2
1 merge request!33feat: Add SportType SQL insert statements for initial data
......@@ -40,8 +40,12 @@ logs-minio:
.PHONY: init-regions
init-regions:
./webapp/backend/scripts/init_regions.sh
bash ./webapp/backend/scripts/init_regions.sh
.PHONY: init-sporttype
init-sporttype:
bash ./webapp/backend/scripts/init_sporttype.sh
.PHONY: init-image-bucket
init-image-bucket:
./webapp/backend/scripts/init_image_bucket.sh
bash ./webapp/backend/scripts/init_image_bucket.sh
#!/bin/bash
DB_CONTAINER_NAME="crewup-mysql-1"
DB_USER="admin"
DB_PASSWORD="localadmin"
DB_NAME="crewup"
SQL_FILE="$(dirname "$0")/init_sporttype.sql"
echo "Checking if the Docker container '${DB_CONTAINER_NAME}' is running..."
if ! docker ps --filter "name=${DB_CONTAINER_NAME}" --format "{{.Names}}" | grep -w "${DB_CONTAINER_NAME}" > /dev/null; then
echo "Error: Docker container '${DB_CONTAINER_NAME}' is not running."
exit 1
fi
if [ ! -f "${SQL_FILE}" ]; then
echo "Error: SQL file '${SQL_FILE}' not found."
exit 1
fi
echo "Copying SQL file to Docker container..."
docker cp "${SQL_FILE}" "${DB_CONTAINER_NAME}:/tmp/$(basename "${SQL_FILE}")"
echo "Applying SQL file to the database '${DB_NAME}'..."
docker exec -i "${DB_CONTAINER_NAME}" sh -c "mysql --default-character-set=utf8 -u${DB_USER} -p${DB_PASSWORD} ${DB_NAME} < /tmp/$(basename "${SQL_FILE}")"
if [ $? -eq 0 ]; then
echo "SQL file successfully applied to the database '${DB_NAME}'."
else
echo "Error: Failed to apply SQL file to the database '${DB_NAME}'."
fi
echo "Cleaning up SQL file from the Docker container..."
docker exec -i "${DB_CONTAINER_NAME}" sh -c "rm -f /tmp/$(basename "${SQL_FILE}")"
echo "Done."
INSERT IGNORE INTO `SportType` (`sportTypeId`, `sportName`, `metadata`)
VALUES
(1, '러닝', '{
"distance": ["3~4km", "5~6km", "7~8km", "9km 이상"],
"pace": ["4:00~4:30", "4:30~5:00", "5:00~5:30", "5:30~6:00", "6:00~6:30", "6:30 이상"]
}'),
(2, '헬스', '{
"experience": ["초보자 (0~1년)", "중급자 (2~3년)", "상급자 (3년 이상)"]
}'),
(3, '클라이밍', '{
"difficulty": ["상관 없음", "V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8+"]
}');
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment