Files
waiting-system/migrate_add_weekday_schedule.py
Jun-dev f699a29a85 Add waiting system application files
- Add main application files (main.py, models.py, schemas.py, etc.)
- Add routers for all features (waiting, attendance, members, etc.)
- Add HTML templates for admin and user interfaces
- Add migration scripts and utility files
- Add Docker configuration
- Add documentation files
- Add .gitignore to exclude database and cache files

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-14 00:29:39 +09:00

78 lines
2.2 KiB
Python
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
교시 테이블에 요일 스케줄 컬럼 추가
ClassInfo 테이블에 weekday_schedule 컬럼을 추가하여
평일/주말 또는 특정 요일별로 클래스를 운영할 수 있도록 합니다.
weekday_schedule 형식 (JSON):
{
"mon": true,
"tue": true,
"wed": true,
"thu": true,
"fri": true,
"sat": false,
"sun": false
}
"""
import sqlite3
import json
def migrate():
conn = sqlite3.connect('waiting_system.db')
cursor = conn.cursor()
try:
# 컬럼 존재 여부 확인
cursor.execute("PRAGMA table_info(class_info)")
columns = [row[1] for row in cursor.fetchall()]
if 'weekday_schedule' not in columns:
print("✅ weekday_schedule 컬럼 추가 중...")
# 기본값: 모든 요일 활성화 (JSON 문자열)
default_schedule = json.dumps({
"mon": True,
"tue": True,
"wed": True,
"thu": True,
"fri": True,
"sat": True,
"sun": True
})
# weekday_schedule 컬럼 추가 (기본값: 모든 요일 활성화)
cursor.execute(f"""
ALTER TABLE class_info
ADD COLUMN weekday_schedule TEXT DEFAULT '{default_schedule}'
""")
# 기존 레코드에 기본값 설정
cursor.execute(f"""
UPDATE class_info
SET weekday_schedule = '{default_schedule}'
WHERE weekday_schedule IS NULL
""")
conn.commit()
print("✅ weekday_schedule 컬럼이 추가되었습니다.")
print(f" 기본값: 모든 요일 활성화")
else:
print(" weekday_schedule 컬럼이 이미 존재합니다.")
except Exception as e:
print(f"❌ 마이그레이션 실패: {e}")
conn.rollback()
finally:
conn.close()
if __name__ == "__main__":
print("=" * 50)
print("ClassInfo 테이블에 weekday_schedule 컬럼 추가")
print("=" * 50)
migrate()
print("=" * 50)
print("✅ 마이그레이션 완료")
print("=" * 50)