Commit Graph

6 Commits

Author SHA1 Message Date
simone 008a43469d feat(10-redo-C): CRM leads module — schema, services, UI (Phase 10 redo)
Stage C of staged Phase 10 redo. Restores dangling phase10-wip work:
- schema.ts: leads expansion + activities/reminders tables + relations
- lead-service.ts / lead-validators.ts service layer
- /admin/leads list + detail + actions, LeadTable/LeadDetail/LeadForm
- LogActivityModal, SendQuoteModal, FollowUpWidget on dashboard
- migration 0005 (applied to prod DB in Stage B, along with
  previously-missing 0001/0003/0004 — root cause of all post-deploy
  500s: prod DB had no migrations applied since 0000)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 20:58:14 +02:00
simone f727954dfb feat(08-02): create Phase 8 migration and validation script
- Create SQL migration 0003_offer_phases_quote_templates.sql
  - Creates offers_phases, offer_phase_services, quotes, leads tables
  - Adds new columns to quote_items, projects, phases (additive-only)
  - Includes proper FK constraints, indexes, and CHECK constraints
  - ZERO DATA LOSS: No drops, no truncates — fully reversible

- Create validation script scripts/validate-phase8-migration.ts
  - Checks all 4 new tables exist
  - Verifies 7 new columns added to existing tables
  - Validates FK references intact
  - Exit code 0 on success, 1 on failure

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-11 07:15:27 +02:00
simone 23a9f8ad8c feat(07-unified-service-catalog): add net-new services informational check to validation script
- Check 6: Count of services with migrated_from IS NULL (net-new rows created via /admin/catalog after migration)
- Printed as informational line at the end of validation output
- Does not fail validation if count is zero (expected for fresh test runs)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-11 06:26:24 +02:00
simone de0888b3ec feat(07-unified-service-catalog): add migration and validation scripts
Task 2: Idempotent backfill script (migrate-services.ts)
- Migrates service_catalog (21 rows) → services with migrated_from='service_catalog'
- Migrates offer_services (35 rows) → services with migrated_from='offer_services'
- Name collision detection: appends ' (Offer)' suffix to prevent overwrites
- Idempotent via (migrated_from, migrated_id) lookups — re-runs are safe no-ops
- Categorizes services: 'catalog' for operational pricing, 'offer' for marketing pricing
- Maps service_catalog.description → services.description
- Maps offer_services.transformation_description → services.description
- Maps service_catalog.unit_price → services.unit_price
- Maps offer_services.price → services.unit_price

Task 3: Validation script (validate-services-migration.ts)
- Check 1: Row counts match (service_catalog/offer_services rows == migrated rows)
- Check 2: No orphaned migrated_id references (all point to existing source rows)
- Check 3: Existing quote_items.service_id FKs remain valid (untouched)
- Check 4: Existing offer_micro_services.service_id FKs remain valid (untouched)
- Check 5: Report any unresolved name collisions (post-migration integrity)
- Exits 0 only if all checks PASS

Plus: push-services-migration.ts helper for direct SQL execution when drizzle-kit unavailable.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-11 06:21:44 +02:00
simone 63c9f750df feat(04-01): multi-project schema migration — projects, settings, FK pivot
- schema.ts: add projects table, settings kv table, slug on clients;
  migrate 6 FK from client_id to project_id (phases, payments, documents, notes,
  time_entries, quote_items); update all relations and TypeScript types
- admin-queries.ts: fix getAllClientsWithPayments + getClientFullDetail to aggregate
  through projects; add getAllProjectsWithPayments, getProjectFullDetail,
  getClientWithProjects, ClientWithProjects type
- settings.ts: new file — getSetting, updateSetting, getTargetHourlyRate, SETTINGS_KEYS
- Fix all downstream files: actions.ts, quote-actions.ts, new/actions.ts,
  timer-actions.ts, approve/route.ts, comment/route.ts, TimerCell.tsx,
  analytics-queries.ts, client-view.ts, seed.ts
- DB migration applied to Coolify Postgres (all test data cleared, schema rebuilt)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 21:58:15 +02:00
Simone Cavalli 073eec7193 feat(seed): add seed script + fix Tailwind scanning adjacent projects
- scripts/seed.ts: inserts one complete test client with 3 phases,
  6 tasks, 4 deliverables, 2 payments, 2 documents, 2 notes; prints
  shareable URL to console
- globals.css: add @source not directives to exclude .01_projects/
  and .claude/ — Tailwind v4 was scanning the SparklingOrbit .venv
  Python files and generating invalid CSS class [-:|] from a regex
  pattern in a markdown-it table parser, causing dev server 500s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 23:33:03 +02:00