
# Database Consolidation Plan (2026-06-23)

## Current State: FRAGMENTED
- Canonical: src/quant_engine/ (2 files)
- Scattered: outputs/ (10) + Temp/ (3)
- Total: 15 database files

## Issue
1. kis_data_collection.db in 3 locations:
   - src/quant_engine/ (CANONICAL)
   - outputs/kis_data_collection/
   - Temp/test_kis_data_collection.db

2. snapshot_admin.db in 4+ locations:
   - src/quant_engine/ (CANONICAL)
   - outputs/snapshot_admin/
   - Temp/snapshot_admin_*.db (multiple variants)
   - outputs/qualitative_sell_strategy/ (unrelated)

## Solution

### Step 1: Verify Canonical Copies (src/quant_engine/)
- kis_data_collection.db: 5 records [OK]
- snapshot_admin.db: 0 records (initialized) [OK]

### Step 2: Archive Scattered Files (archive_db/)
Create archive directory with timestamp:
```
archive_db/
├── 2026-06-23_outputs_kis_data_collection/
├── 2026-06-23_outputs_snapshot_admin/
├── 2026-06-23_temp_test_files/
└── manifest.json (record what was archived)
```

### Step 3: Clean Obsolete References
- Remove imports from "outputs/kis_data_collection/kis_data_collection.db"
- Remove imports from "outputs/snapshot_admin/*.db"
- Update any code expecting these paths

### Step 4: Update Documentation
- Update all references to use: src/quant_engine/
- Update deployment docs (Synology)
- Update CI/CD workflows

## Benefits
- Single source of truth
- Easier backup/recovery
- Clear separation: live vs. archived
- Faster data access
- Simplified deployment

## Files to Delete (After Archiving)
- outputs/kis_data_collection/ (entire dir)
- outputs/snapshot_admin/smoke*.db (old test files)
- outputs/qualitative_sell_strategy/qualitative_sell_strategy.db
- Temp/snapshot_admin_*.db
- Temp/test_kis_data_collection.db
