Add shared bible submodule, rename local bible to bible-local

- Add bible.git as submodule at bible/
- Rename bible/ → bible-local/ (project-specific architecture)
- Update CLAUDE.md to reference both bible/ and bible-local/
- Add AGENTS.md for Codex with same structure

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 16:37:10 +03:00
parent 09593019b1
commit c5d253a9df
20 changed files with 26 additions and 1 deletions

View File

@@ -0,0 +1,162 @@
# String ID Migration - Final Implementation Status
## ✅ COMPLETED WORK
### Phase 1: ID Generation Infrastructure (100% Complete)
- ✅ Created id_sequences table with migration
- ✅ Implemented thread-safe ID generator service
- ✅ Comprehensive tests including concurrency testing
- ✅ Verified working with production database
### Phase 2: Dual-Write Period (100% Complete)
- ✅ Migration 0010 created and applied
- ✅ All existing data backfilled with formatted IDs
- ✅ All domain models updated with dual ID fields
- ✅ All 9 repositories updated for dual-write
### Phase 3: String IDs Only (95% Complete)
#### ✅ Completed
1. **Migration Created**: `migrations/0011_switch_to_string_ids/up.sql`
- Ready to apply (not yet applied)
- Drops all integer ID columns
- Promotes string IDs to primary
2. **Domain Models** (3/3 files - 100%)
-`/internal/domain/registry.go`
-`/internal/domain/tickets.go`
-`/internal/domain/failure_events.go`
3. **Repositories** (9/10 files - 90%)
-`/internal/repository/registry/customers.go`
-`/internal/repository/registry/projects.go`
-`/internal/repository/registry/locations.go`
-`/internal/repository/registry/lots.go`
-`/internal/repository/registry/assets.go`
-`/internal/repository/registry/components.go`
-`/internal/repository/registry/installations.go`
-`/internal/repository/tickets/tickets.go`
-`/internal/repository/failures/failures.go`
-**REMAINING**: `/internal/repository/timeline/events.go`
4. **API Layer** (80% Complete)
- ✅ Updated `parseID()` helper to handle string IDs
- ✅ Updated request structs in `registry.go`
- ✅ Updated request structs in `failures.go`
- ✅ Updated request structs in `tickets.go`
-**REMAINING**: Timeline handlers in `ui.go`
## ⏳ REMAINING WORK (Estimated: 30 minutes)
### 1. Update Timeline Repository
**File**: `/internal/repository/timeline/events.go`
Changes needed:
```go
// Change Cursor struct
type Cursor struct {
Time time.Time
ID string // was: int64
}
// Update List method signature
func (r *EventRepository) List(ctx context.Context, subjectType string, subjectID string, ...) // was: int64
// Update cursor encoding/decoding to handle string IDs
```
### 2. Update UI Handlers
**File**: `/internal/api/ui.go`
Find and update these calls:
- Line 316: `h.deps.Timeline.List(...)` - pass string ID instead of int64
- Line 414: `h.deps.Timeline.List(...)` - pass string ID instead of int64
### 3. Update Ingest Service (if exists)
Check `/internal/ingest/` for any code that creates or references entities by ID.
### 4. Compilation Test
```bash
go build ./...
```
Fix any remaining compilation errors.
## DEPLOYMENT STEPS
### 1. Pre-Deployment Checklist
- [ ] Full database backup
- [ ] All tests passing: `go test ./...`
- [ ] Code compiles: `go build ./...`
- [ ] Dry-run migration on test database
### 2. Apply Migration
```bash
# Backup first!
docker exec reanimator-mariadb mariadb-dump -u reanimator -preanimator reanimator > backup_before_string_ids_$(date +%Y%m%d_%H%M%S).sql
# Apply migration
docker exec -i reanimator-mariadb mariadb -u reanimator -preanimator reanimator < migrations/0011_switch_to_string_ids/up.sql
# Verify schema
docker exec -i reanimator-mariadb mariadb -u reanimator -preanimator reanimator -e "DESCRIBE customers"
```
### 3. Verify
```bash
# Compile and run
go build ./...
go run ./cmd/reanimator-api
# Test API
curl http://localhost:9999/customers
# Should return customers with string IDs like "CR-0000001"
# Create new customer
curl -X POST http://localhost:9999/customers -H "Content-Type: application/json" -d '{"name": "Test Company"}'
# Should return: {"id": "CR-000000X", ...}
```
## BENEFITS ACHIEVED
**Human-Readable IDs**: `CR-0000001` instead of `1`
**Self-Documenting**: Entity type visible in ID
**Better UX**: Copy-paste friendly, easy to communicate
**Future-Proof**: No integer overflow, supports distributed systems
**Cleaner Code**: No more int64 parsing, simpler API
## ROLLBACK PLAN
⚠️ **WARNING**: Migration 0011 is NOT easily reversible!
**Options**:
1. **Restore from backup** (recommended)
```bash
docker exec -i reanimator-mariadb mariadb -u reanimator -preanimator reanimator < backup_before_string_ids_TIMESTAMP.sql
```
2. **Manual rollback** (complex, requires downtime)
- Would need to recreate auto-increment columns
- Would lose the formatted string IDs
- Not recommended unless absolutely necessary
## SUMMARY
**Total Implementation Time**: ~6 hours
**Lines of Code Changed**: ~2000+
- Domain models: 3 files
- Repositories: 10 files
- API handlers: 5+ files
- Migrations: 3 migrations
**Risk Level**: Medium
- Phase 1 & 2: ✅ Zero risk (fully backwards compatible)
- Phase 3: ⚠️ Breaking change (requires migration)
**Current State**: Ready for final testing and deployment
- 95% code complete
- Migration ready
- Just need to finish timeline repository and test
**Recommendation**: Complete the remaining 5% (timeline updates), test thoroughly, then apply migration during low-traffic period.