Spaces:
Sleeping
Sleeping
File size: 2,812 Bytes
fdd1575 82c1146 fdd1575 82c1146 fdd1575 82c1146 fdd1575 82c1146 fdd1575 82c1146 |
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 |
#!/bin/bash
# ============================================================================
# SmartEye OCR Database Reset Script (v2.1)
# ============================================================================
# κΈ°λ₯:
# - Docker MySQL 컨ν
μ΄λμμ DB μμ μ΄κΈ°ν
# - init_db_complete.sql μλ μ€ν (ν
μ΄λΈ + μ΄κΈ° λ°μ΄ν°)
# - combined_text: MEDIUMTEXT (16MB μ§μ)
# ============================================================================
set -e # μλ¬ μ μ¦μ μ€λ¨
# μμ μ μ
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}======================================${NC}"
echo -e "${YELLOW}SmartEye OCR Database Reset${NC}"
echo -e "${YELLOW}======================================${NC}"
# 1. Docker 컨ν
μ΄λ νμΈ
CONTAINER_NAME="smart_mysql"
if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
echo -e "${RED}Error: Docker container '${CONTAINER_NAME}' is not running${NC}"
echo -e "${YELLOW}Please start with: cd Backend && docker-compose up -d${NC}"
exit 1
fi
# 2. μ€ν¬λ¦½νΈ κ²½λ‘ νμΈ
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SQL_FILE="${SCRIPT_DIR}/init_db_complete.sql"
if [ ! -f "$SQL_FILE" ]; then
echo -e "${RED}Error: $SQL_FILE not found${NC}"
exit 1
fi
# 3. μ¬μ©μ νμΈ
echo -e "${YELLOW}β οΈ Warning: This will DELETE all existing data!${NC}"
echo -e "${YELLOW}Database: smarteyessen_db${NC}"
read -p "Continue? (yes/no): " confirm
if [ "$confirm" != "yes" ]; then
echo -e "${GREEN}Cancelled.${NC}"
exit 0
fi
# 4. DB μ΄κΈ°ν μ€ν
echo -e "${GREEN}Resetting database...${NC}"
docker exec -i ${CONTAINER_NAME} mysql -u root -p1q2w3e4r < "$SQL_FILE"
if [ $? -eq 0 ]; then
echo -e "${GREEN}======================================${NC}"
echo -e "${GREEN}β
Database reset completed!${NC}"
echo -e "${GREEN}======================================${NC}"
echo ""
echo "π Created tables:"
echo " - users, document_types, projects, pages"
echo " - layout_elements, text_contents, ai_descriptions"
echo " - question_groups, question_elements"
echo " - text_versions, formatting_rules"
echo " - combined_results (LONGTEXT, up to 4GB)"
echo ""
echo "οΏ½ Initial data:"
echo " - 2 document types (worksheet, document)"
echo " - 25+ formatting rules (auto-generated)"
echo ""
echo "π Next steps:"
echo " 1. Start backend: uvicorn Backend.app.main:app --reload"
echo " 2. Check health: curl http://localhost:8000/health"
else
echo -e "${RED}β Database reset failed!${NC}"
exit 1
fi
echo "β
Table initialization complete."
echo "π Database reset finished. You can now rerun backend services or seed data as needed."
|