# task-435.1: InsuRo feature_definitions + subscription_plans seed 데이터 등록

## 한시적 승인
제이회장님이 이 작업 범위 내에서 자율 진행 승인함. 완료까지 자율 체이닝.

## 배경
- InsuRo 프로젝트: `/home/jay/projects/InsuRo/`
- Supabase URL: `.env` 파일 참조
- DB 마이그레이션 시 테이블 구조만 생성, **seed 데이터 미포함**
- `subscription_plans`, `feature_definitions` 두 테이블 모두 0건
- 관리자 페이지 (`AdminSubscriptions.tsx`)는 완벽히 구현되어 있음 — 데이터만 없음

## 작업 내용

### 1. feature_definitions 테이블 seed

`feature_definitions` 테이블에 InsuRo의 모든 기능을 등록한다.
AdminSubscriptions.tsx의 카테고리 참조:
- `menu`: 메뉴 접근 (boolean)
- `ai_token`: AI 토큰 기능 (boolean/number)
- `limit`: 수량 제한 (number)
- `org`: 조직 기능 (boolean)

**등록할 기능 목록** (코드베이스에서 `useFeatureGate` 사용처 + PlanUpgradeDialog 참고):

메뉴 접근 (category: menu):
- `ai_generate` — AI 콘텐츠 생성
- `content_calendar` — 콘텐츠 캘린더
- `insurance_tools` — 보험 도구
- `ai_health_analysis` — AI 건강분석
- `ai_design_proposal` — AI 디자인 제안
- `digital_namecard` — 디지털 명함
- `keyword_tools` — 키워드 분석

AI 토큰 (category: ai_token):
- `ai_provider` — AI 프로바이더 (value_type: string, 기본값: "gemini-flash-lite")
  - 값: "gemini-flash-lite" / "gemini-flash" / "claude-haiku" / "claude-sonnet"
- `ai_image_generate` — AI 이미지 생성 (boolean)

수량 제한 (category: limit):
- `max_contents_per_month` — 월간 콘텐츠 생성 횟수 (number, -1=무제한)
- `max_images_per_month` — 월간 이미지 생성 횟수 (number, -1=무제한)
- `max_images_per_generation` — 회당 이미지 생성 수 (number)

조직 기능 (category: org):
- `org_management` — 조직 관리
- `agent_management` — 에이전트 관리

⚠️ `ai_provider`는 value_type이 "string"인데, 현재 AdminSubscriptions UI는 boolean/number만 지원.
→ value_type: "string"으로 등록하되, 당분간 관리자가 직접 JSON 편집하거나, UI에 select 드롭다운 추가 필요.
→ 이번 작업에서는 일단 seed만 하고, UI 개선은 별도 이슈로.

### 2. subscription_plans 테이블 seed

5개 플랜을 등록한다. PlanUpgradeDialog.tsx 참고하되, features는 DB feature_definitions 기준으로.

**Free** (sort_order: 0, price: 0)
```json
{
  "ai_generate": true,
  "content_calendar": false,
  "insurance_tools": false,
  "ai_health_analysis": false,
  "ai_design_proposal": false,
  "digital_namecard": true,
  "keyword_tools": false,
  "ai_provider": "gemini-flash-lite",
  "ai_image_generate": false,
  "max_contents_per_month": 3,
  "max_images_per_month": 0,
  "max_images_per_generation": 0,
  "org_management": false,
  "agent_management": false
}
```

**Basic** (sort_order: 1, price: 29000)
```json
{
  "ai_generate": true,
  "content_calendar": true,
  "insurance_tools": false,
  "ai_health_analysis": false,
  "ai_design_proposal": false,
  "digital_namecard": true,
  "keyword_tools": false,
  "ai_provider": "gemini-flash-lite",
  "ai_image_generate": true,
  "max_contents_per_month": 30,
  "max_images_per_month": 20,
  "max_images_per_generation": 2,
  "org_management": false,
  "agent_management": false
}
```

**Pro** (sort_order: 2, price: 59000, 인기 플랜)
```json
{
  "ai_generate": true,
  "content_calendar": true,
  "insurance_tools": true,
  "ai_health_analysis": true,
  "ai_design_proposal": false,
  "digital_namecard": true,
  "keyword_tools": true,
  "ai_provider": "gemini-flash",
  "ai_image_generate": true,
  "max_contents_per_month": 100,
  "max_images_per_month": 100,
  "max_images_per_generation": 6,
  "org_management": false,
  "agent_management": false
}
```

**Premium** (sort_order: 3, price: 99000)
```json
{
  "ai_generate": true,
  "content_calendar": true,
  "insurance_tools": true,
  "ai_health_analysis": true,
  "ai_design_proposal": true,
  "digital_namecard": true,
  "keyword_tools": true,
  "ai_provider": "claude-haiku",
  "ai_image_generate": true,
  "max_contents_per_month": 300,
  "max_images_per_month": 300,
  "max_images_per_generation": 8,
  "org_management": false,
  "agent_management": false
}
```

**Enterprise** (sort_order: 4, price: 0 — 별도 협의)
```json
{
  "ai_generate": true,
  "content_calendar": true,
  "insurance_tools": true,
  "ai_health_analysis": true,
  "ai_design_proposal": true,
  "digital_namecard": true,
  "keyword_tools": true,
  "ai_provider": "claude-sonnet",
  "ai_image_generate": true,
  "max_contents_per_month": -1,
  "max_images_per_month": -1,
  "max_images_per_generation": 8,
  "org_management": true,
  "agent_management": true
}
```

### 3. 구현 방법

Supabase REST API를 사용해서 직접 insert:
```bash
source /home/jay/projects/InsuRo/.env
SUPABASE_URL="$VITE_SUPABASE_URL"
SUPABASE_KEY="$VITE_SUPABASE_PUBLISHABLE_KEY"

curl -X POST "${SUPABASE_URL}/rest/v1/feature_definitions" \
  -H "apikey: ${SUPABASE_KEY}" \
  -H "Authorization: Bearer ${SUPABASE_KEY}" \
  -H "Content-Type: application/json" \
  -d '[{...}]'
```

⚠️ RLS 정책으로 anon key가 insert 권한 없을 수 있음.
그 경우: Supabase 마이그레이션 SQL 파일을 작성하여 `supabase db push` 또는 Supabase Dashboard SQL Editor에서 실행.

### 4. 검증
- REST API로 select 해서 데이터 확인
- InsuRo 프리뷰에서 관리자 > 구독 플랜 관리 페이지 열어서 플랜 카드 표시 확인

## 레벨: Lv.1
데이터 삽입 작업. 스키마 변경 없음.