Phase 1 of Migration. Running Scripts

This commit is contained in:
2026-04-17 15:11:12 +03:00
parent 0a8a42d69b
commit 4c2400b596
15 changed files with 1094 additions and 2 deletions

View File

@@ -465,11 +465,61 @@ backend/
| Phase | Description | Status |
|-------|-------------|--------|
| 0 | Schema foundation (all tables in Postgres) | **COMPLETE** (local) — run `alembic upgrade head` on VPS |
| 1 | SQLite → Postgres (data migration) | NOT STARTED |
| 0 | Schema foundation (all tables in Postgres) | **COMPLETE** — applied on VPS 2026-04-17 |
| 1 | SQLite → Postgres (data migration) | **IN PROGRESS** — scripts written, not yet run |
| 2 | Firestore → Postgres (data migration) | NOT STARTED |
| 3 | Staff auth cutover | NOT STARTED |
| 4 | Audit log system | NOT STARTED |
| 5 | MQTT live data cutover | NOT STARTED |
Update this table as each phase completes.
---
## Phase 1 — Run Order & Commands
Run each command on the VPS **in order**. Verify the output of each before proceeding.
```bash
# 1.1
docker compose exec backend python -m migration.migrate_melody_drafts
# 1.2
docker compose exec backend python -m migration.migrate_built_melodies
# 1.3
docker compose exec backend python -m migration.migrate_mfg_audit_log
# 1.4
docker compose exec backend python -m migration.migrate_device_alerts
# 1.5
docker compose exec backend python -m migration.migrate_crm_sync_state
# 1.6 (FK enforcement suppressed — crm_customers not in PG yet)
docker compose exec backend python -m migration.migrate_crm_quotations
# 1.7
docker compose exec backend python -m migration.migrate_crm_quotation_items
# 1.8
docker compose exec backend python -m migration.migrate_crm_media
# 1.9
docker compose exec backend python -m migration.migrate_crm_comms_log
# 1.10
docker compose exec backend python -m migration.migrate_commands
# 1.11
docker compose exec backend python -m migration.migrate_heartbeats
# 1.12 (largest — batched, shows progress)
docker compose exec backend python -m migration.migrate_device_logs
```
After all scripts complete, verify the run log:
```bash
docker compose exec postgres psql -U bellsystems_user -d bellsystems_db \
-c "SELECT script_name, ran_at, source_rows, dest_rows, success FROM _migration_runs ORDER BY ran_at;"
```