본문으로 건너뛰기

Billing 스키마 ERD

개요

빌링 테이블은 물리적으로 public 스키마 내에 있습니다. 별도 billing 스키마는 존재하지 않습니다.

결제 게이트웨이는 Toss Payments입니다. 플랫폼 빌링과 학원 수납 두 계층으로 구성됩니다.

플랫폼 빌링 ERD

학원 수납 ERD (tenant_id + RLS)

테이블 상세

플랫폼 빌링 (RLS 없음)

테이블설명
plans구독 플랜 카탈로그. custom_domains 컬럼 V49에서 제거
billing_keysToss billingKey (자동결제 토큰). 테넌트당 ACTIVE 1개
subscriptions테넌트 구독 상태. 1:1 per tenant
invoicesLumie→학원 청구서
alimtalk_credits카카오 알림톡 크레딧 잔액
payment_transactionsPG 호출 감사 로그 (불변, append-only)
tax_invoices세금계산서
billing_operation_locks진행 중인 빌링 작업 뮤텍스 (ephemeral)

학원 수납 (tenant_id + RLS)

테이블설명
merchant_profilesToss 서브머천트 KYC. 테넌트당 1개. pg_seller_key 승인 후 발급
guardians학부모/법정대리인
student_guardians학생-보호자 M:N 매핑
tuition_invoices학원→학부모/학생 수납 청구서
tuition_payments수납 결제 이벤트
cash_receipts현금영수증

merchant_profiles는 직접 수납(direct-Toss tuition payment) 기능이 제거된 후에도 테이블은 유지됩니다.

마이그레이션 이력

버전내용
V28플랫폼 빌링 테이블 신설 + lumie_app 권한 부여
V29학원 수납 테이블 신설 + RLS 정책
V31billing 누락 컬럼 추가
V33billing_keys.customer_key 추가
V34plans 시드 데이터 (FREE/BASIC/PRO/MAX)
V37subscriptions pending_plan_id, scheduled_change_at 추가
V38billing_operation_locks 신설
V49plans.custom_domains 제거
V51ENTERPRISE → MAX 리네임