Commit Graph
4 Commits
Author SHA1 Message Date
GustavoandClaude Sonnet 5 40bd8d096e Fix v15 migration test to drop v19 table before replaying migrations
The v15 test pattern (delete migration records >= 15, drop schema, reopen to replay)
was failing because outreach_shared_number_overrides table from v19 migration was not
dropped before replaying. Add DROP TABLE IF EXISTS to the schema cleanup block to
match the same fix applied to v17 test.

This resolves the 'table already exists' error during v19 migration replay.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-31 11:04:22 -03:00
GustavoandClaude Sonnet 5 fe70436dbb Add shared-number detection and override data layer
- Add migration v19: creates outreach_shared_number_overrides table
- Implement 7 new data-layer functions:
  - leadsSharingNumber: find leads sharing a phone number variant
  - isNumberSharedAcrossLeads: detect if number is shared by 2+ leads
  - getSharedNumberOverride: retrieve override entry for a number
  - isSharedNumberOverridden: check if number has an override
  - addSharedNumberOverride: create or update override with reason
  - removeSharedNumberOverride: delete override record
  - listSharedNumberGroups: group leads by shared numbers, reflect override state
- Add 4 comprehensive tests covering migration, detection, override crud, and grouping
- Update version assertions from 18 to 19
- Fix v17 migration test to properly clean up v19 table for schema reset

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-31 10:59:29 -03:00
Gustavo d330bb5ff0 Baseline commit of the existing Maquina Comercial Pessoal project
Tracks the app that was already in place (capture, treatment, outreach,
WhatsApp integration, server, frontend, tests, docs) so future feature
work can branch and use isolated worktrees.
2026-07-31 10:54:07 -03:00
Gustavo 6cd336a41e Add design spec for shared-number detection in outreach
Detects when a WhatsApp number is shared by multiple leads (e.g. an
accountant's phone reused across client CNPJs) and blocks automatic
and manual outreach to all of them until an operator reviews and
releases the number.
2026-07-31 10:36:02 -03:00