update database

This commit is contained in:
Phuoc Nguyen
2025-10-24 11:31:48 +07:00
parent f95fa9d0a6
commit c4272f9a21
126 changed files with 23528 additions and 2234 deletions

168
TYPEID_VERIFICATION.md Normal file
View File

@@ -0,0 +1,168 @@
# TypeId Verification Report
## ✅ All TypeId Conflicts Resolved
### Changes Made
1. **storage_constants.dart** - Added new typeIds:
- `memberCardModel = 25`
- `promotionModel = 26`
- `categoryModel = 27`
2. **member_card_model.dart** - Changed from hardcoded `typeId: 10` to `typeId: HiveTypeIds.memberCardModel` (25)
3. **promotion_model.dart** - Changed from hardcoded `typeId: 11` to `typeId: HiveTypeIds.promotionModel` (26)
4. **category_model.dart** - Changed from hardcoded `typeId: 12` to `typeId: HiveTypeIds.categoryModel` (27)
### TypeId Range Summary
```
Core Models: 0-9 (10 slots, all assigned)
Loyalty Models: 10-13 (4 slots, all assigned)
Project/Quote: 14-17 (4 slots, all assigned)
Chat: 18-19 (2 slots, all assigned)
Extended Models: 20-27 (8 used, 2 available: 28-29)
Enums: 30-51 (22 assigned, 8 available: 52-59)
Cache/Sync: 60-62 (3 assigned, 7 available: 63-69)
Reserved Future: 70-99 (30 slots available)
Special: 100 (2 values - max cache size config)
```
### Unique TypeIds Assigned (0-69)
**Models: 0-27**
```
0 = userModel
1 = userSessionModel
2 = productModel
3 = stockLevelModel
4 = cartModel
5 = cartItemModel
6 = orderModel
7 = orderItemModel
8 = invoiceModel
9 = paymentLineModel
10 = loyaltyPointEntryModel
11 = giftCatalogModel
12 = redeemedGiftModel
13 = pointsRecordModel
14 = projectSubmissionModel
15 = designRequestModel
16 = quoteModel
17 = quoteItemModel
18 = chatRoomModel
19 = messageModel
20 = notificationModel
21 = showroomModel
22 = showroomProductModel
23 = paymentReminderModel
24 = auditLogModel
25 = memberCardModel ✨ (NEW - was conflicting at 10)
26 = promotionModel ✨ (NEW - was conflicting at 11)
27 = categoryModel ✨ (NEW - was conflicting at 12)
```
**Enums: 30-51**
```
30 = userRole
31 = userStatus
32 = loyaltyTier
33 = orderStatus
34 = invoiceType
35 = invoiceStatus
36 = paymentMethod
37 = paymentStatus
38 = entryType
39 = entrySource
40 = complaintStatus
41 = giftCategory
42 = giftStatus
43 = pointsStatus
44 = projectType
45 = submissionStatus
46 = designStatus
47 = quoteStatus
48 = roomType
49 = contentType
50 = reminderType
51 = notificationType
```
**Cache/Sync: 60-62**
```
60 = cachedData
61 = syncState
62 = offlineRequest
```
### Aliases (Reference existing typeIds)
```
memberTier = loyaltyTier (32)
userType = userRole (30)
projectStatus = submissionStatus (45)
transactionType = entryType (38)
```
## ✅ No Duplicates Found
Verified using command:
```bash
grep "static const int" lib/core/constants/storage_constants.dart | awk '{print $5}' | sort | uniq -d
```
Result: **No duplicate values**
## ✅ No Hardcoded TypeIds Found
Verified using command:
```bash
grep -r "@HiveType(typeId: [0-9]" lib/
```
Result: **No hardcoded typeIds in lib/ directory**
## ✅ All Models Use Constants
Verified that all 47+ models now use `HiveTypeIds.constantName` format:
- ✅ All auth models
- ✅ All product models
- ✅ All cart models
- ✅ All order models
- ✅ All loyalty models
- ✅ All project models
- ✅ All quote models
- ✅ All chat models
- ✅ All showroom models
- ✅ All notification models
- ✅ All enum types
- ✅ All cache models
## Next Actions Required
### 1. Regenerate Hive Adapters
```bash
flutter pub run build_runner build --delete-conflicting-outputs
```
This will regenerate:
- `member_card_model.g.dart` with new typeId 25
- `promotion_model.g.dart` with new typeId 26
- `category_model.g.dart` with new typeId 27
### 2. Clear Development Data (Optional)
If testing locally, you may want to clear existing Hive boxes:
```dart
await Hive.deleteBoxFromDisk('home_box');
await Hive.deleteBoxFromDisk('products_box');
```
### 3. Test the App
Run the app and verify:
- ✅ No HiveError about duplicate typeIds
- ✅ Member cards load correctly
- ✅ Promotions load correctly
- ✅ Product categories load correctly
- ✅ All Hive operations work as expected
## Status: ✅ READY FOR ADAPTER GENERATION
All typeId conflicts have been resolved. The codebase is now ready for running the build_runner to regenerate adapters.