b0503baac5
2. callcenter 프로젝트 제작중
28 lines
854 B
Python
28 lines
854 B
Python
# 강제로 회원가입
|
|
from sqlalchemy.orm import Session
|
|
from backend.repository.db_init import SessionLocal
|
|
from backend.repository.models import Customer
|
|
|
|
db = SessionLocal()
|
|
|
|
DEFAULT_CUSTOMERS = [
|
|
Customer(name="홍길동", phone="010-1234-5678"),
|
|
Customer(name="최철수", phone="010-4321-8765"),
|
|
Customer(name="박영희", phone="010-5678-1234"),
|
|
]
|
|
|
|
def seed_customers(db: Session):
|
|
"""
|
|
customer 테이블에 기본(연습용) 회원 데이터 삽입
|
|
(중복 실행 방지 : 이미 데이터가 있으면 건너뜀)
|
|
"""
|
|
|
|
existing = db.query(Customer).first()
|
|
if existing:
|
|
print("[Seed] customer 테이블에 이미 데이터가 있습니다.")
|
|
return
|
|
|
|
db.add_all(DEFAULT_CUSTOMERS)
|
|
db.commit()
|
|
db.close()
|
|
print(f"[Seed] 기본 회원 {len(DEFAULT_CUSTOMERS)}명 생성 완료") |