fix(schema): 입금자명 길이 제한 50자 → 15자로 조정
근거: - SMS 입금자명: 한글 7자 제한 (은행 시스템) - 사용자 수동 입력: 15자로 충분한 여유 - 매칭 로직: 앞 7자만 사용 변경사항: - CHECK (length(depositor_name) <= 50) → 15 - 데이터 복원 시 truncate: 50자 → 15자 - SCHEMA_MIGRATION_GUIDE.md 업데이트 - MIGRATION_SUMMARY.md 업데이트 로컬 테스트 결과: - ✅ 15자 이하: 정상 입력 - 숫자 15자: "123456789012345" ✓ - 한글 15자: "홍길동아버지어머니할머님고모고" ✓ - ✅ 16자 이상: 거부됨 - 숫자 16자: "1234567890123456" ✗ (CHECK 제약조건) - 한글 16자: "홍길동아버지어머니할머님고모고모" ✗ (CHECK 제약조건) 실용성: - SMS 7자 보장 + 사용자 입력 여유 - 불필요한 긴 이름 방지 - 매칭 로직과 완벽 호환 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,7 @@ This migration adds critical data integrity constraints and audit logging capabi
|
||||
| Change | Purpose | Risk Level |
|
||||
|--------|---------|------------|
|
||||
| `user_deposits.balance` CHECK constraint | Prevent negative balances | Medium |
|
||||
| `deposit_transactions.depositor_name` length limit | Enforce 50 character max | Low |
|
||||
| `deposit_transactions.depositor_name` length limit | Enforce 15 character max | Low |
|
||||
| `audit_logs` table | Track all important operations | None (new table) |
|
||||
|
||||
---
|
||||
@@ -46,20 +46,20 @@ INSERT INTO user_deposits (user_id, balance) VALUES (999999, -1000);
|
||||
|
||||
### 2. Depositor Name Length (`deposit_transactions`)
|
||||
|
||||
**Goal**: Limit `depositor_name` to 50 characters max
|
||||
**Goal**: Limit `depositor_name` to 15 characters max
|
||||
|
||||
**Implementation**:
|
||||
```sql
|
||||
CREATE TABLE deposit_transactions (
|
||||
...
|
||||
depositor_name TEXT CHECK (length(depositor_name) <= 50),
|
||||
depositor_name TEXT CHECK (length(depositor_name) <= 15),
|
||||
...
|
||||
);
|
||||
```
|
||||
|
||||
**Impact**:
|
||||
- ✅ Prevents excessively long names
|
||||
- 📏 Truncates existing names >50 chars (logs truncated records)
|
||||
- 📏 Truncates existing names >15 chars (logs truncated records)
|
||||
- 🔧 Requires table recreation (SQLite limitation)
|
||||
|
||||
**Verification**:
|
||||
@@ -137,7 +137,7 @@ wrangler d1 execute telegram-conversations \
|
||||
|
||||
# Check for long depositor names (will be truncated)
|
||||
wrangler d1 execute telegram-conversations \
|
||||
--command "SELECT id, depositor_name, length(depositor_name) as len FROM deposit_transactions WHERE length(depositor_name) > 50"
|
||||
--command "SELECT id, depositor_name, length(depositor_name) as len FROM deposit_transactions WHERE length(depositor_name) > 15"
|
||||
```
|
||||
|
||||
### 3. Notify Users (if downtime expected)
|
||||
@@ -496,7 +496,7 @@ wrangler d1 execute telegram-conversations \
|
||||
After migration, verify:
|
||||
|
||||
- [ ] All user_deposits records have `balance >= 0`
|
||||
- [ ] All deposit_transactions have `depositor_name` length <= 50
|
||||
- [ ] All deposit_transactions have `depositor_name` length <= 15
|
||||
- [ ] audit_logs table exists with correct schema
|
||||
- [ ] All indexes recreated successfully
|
||||
- [ ] Record counts match pre-migration
|
||||
|
||||
Reference in New Issue
Block a user