companies 스키마
회사(기업) 본문 문서의 전체 스키마. 회사 가입, 정보 변경, 조회 등에서 사용됩니다.
저장 위치
회사 ID는 database.write(collection="companies", ...) 호출 시 자동 생성됩니다 (login/sign_up.py의 _company_registration).
생성/변경 흐름
회사 최초 가입 (_company_registration)
├── companies/{company_id} 생성
├── companies/{company_id}/settings/tags 생성
├── companies/{company_id}/settings/site_tags 생성
├── companies/{company_id}/settings/drive_usage 생성
├── companies/{company_id}/settings/ai_credit 생성
├── companies/{company_id}/members/{owner_UID} 생성 (role=owner)
└── users/{owner_UID}/membership/{company_id} 생성
owner가 정보 변경 (_change_company_info)
└── companies/{company_id} update (name/registration_number/phone/address/updated_at/update_UID)
문서 필드
| 필드 | 타입 | 설명 |
|---|---|---|
name |
string | 회사명 |
registration_number |
string | 사업자 등록번호 (고유, 중복 불가) |
owner_UID |
string | 회사 소유자의 UID (고유, 한 사람이 한 회사만 소유 가능) |
owner_name |
string | 소유자 이름 (평문, 암호화된 users.name_enc에서 복호화) |
main_address |
string | 기본 주소 |
sub_address |
string | 상세 주소 (회사는 평문 저장, 사용자와 달리 암호화 안 함) |
phone |
string | 회사 대표 전화번호 (tel 형식) |
authentication |
boolean | 사업자 인증 여부 (기본 false) |
created_at |
timestamp | 최초 생성 시각 (firestore.SERVER_TIMESTAMP) |
updated_at |
timestamp? | 마지막 정보 수정 시각 (_change_company_info에서만 기록) |
update_UID |
string? | 마지막 정보 수정자 UID |
중복 체크 규칙
owner_UID중복: 한 사용자는 한 회사만 소유 가능 (_check_duplicate("companies", {"owner_UID": UID}))registration_number중복: 동일 사업자 등록번호는 하나만 등록 가능
관련 서브컬렉션
회사 하위에 붙는 모든 서브컬렉션 목록:
| 경로 | 설명 |
|---|---|
companies/{cid}/members/{uid} |
회사 멤버 (owner/admin/manager) |
companies/{cid}/membership_requests/{request_id} |
회사 가입 요청 |
companies/{cid}/attendance_logs/{log_id} |
회사 출퇴근 로그 |
companies/{cid}/attendance_requests/{request_id} |
회사 출퇴근 요청 |
companies/{cid}/delete_logs/{log_id} |
삭제 이력 |
companies/{cid}/settings/{doc_id} |
회사 설정 문서들 (tags, site_tags, drive_usage, ai_credit 등) |
companies/{cid}/sites/{site_id} |
현장 문서 |
companies/{cid}/sites/{site_id}/supervisor/{uid} |
현장 감독자 |
예시 문서
{
"name": "가나다건설",
"registration_number": "123-45-67890",
"owner_UID": "firebase_uid_1",
"owner_name": "홍길동",
"main_address": "서울특별시 강남구 테헤란로 1",
"sub_address": "10층 1001호",
"phone": "02-1234-5678",
"authentication": false,
"created_at": "2026-04-20T10:00:00Z",
"updated_at": "2026-04-21T09:00:00Z",
"update_UID": "firebase_uid_1"
}