---
phase: 12
plan: 02
type: execute
status: complete
wave: 2
completed: 2026-06-15
---

# 12-02 SUMMARY — Apply migration 0008 to production (BLOCKING checkpoint)

## What was done

Migration `0008_offer_tier_schema.sql` (created in Plan 01) was applied to the
**production** database via the idempotent push script, run from the local
environment through an operator-opened SSH tunnel (local `127.0.0.1:54321` →
production host Postgres `localhost:54321`).

Command used (credentials read from `.env.local`, host/port rewritten to the
tunnel endpoint via `URL()` — never printed):

```bash
DATABASE_URL=$(node --env-file=.env.local -e 'const u=new URL(process.env.DATABASE_URL); u.host="127.0.0.1:54321"; process.stdout.write(u.toString())') \
  npx tsx scripts/push-12-offer-tier-schema.ts
```

Script output: all 14 statements reported `ready` — `✓ Migration 0008 (offer tier schema) applied successfully`.

## Verification (against live prod)

- `offer_macros` gained: `description, category, ticket, is_archived, cliente_ideale, risultato, tempo, pain, metodo` ✓
- `offer_micros` gained: `tier_letter`, `public_price` ✓
- Constraint `offer_micros_tier_letter_check` present ✓
- Table `offer_tier_services` exists with columns `tier_id, service_id, created_at` ✓
- Row counts unchanged (additive, no data loss): `offer_macros=1, offer_micros=1, clients=4, projects=5, payments=13, phases=6` ✓

## Issues Encountered

- First attempts failed: direct `178.104.27.55:54321` → `CONNECT_TIMEOUT` (firewalled, as in Phase 11); then through the tunnel `ECONNRESET` on all SSL variants. Root cause: the SSH `-L` forward initially targeted the wrong remote port; once re-opened pointing at the prod host's published Postgres port (`localhost:54321`), `SELECT 1` succeeded and the migration applied cleanly.

## Self-Check: PASSED

Migration 0008 is live on production; all new columns/constraint/table queryable; no destructive changes; Waves 3–4 schema-dependent code is now unblocked.
