Skip to content

Consolidate three fulfil contact tables into one#52

Open
devinsays wants to merge 1 commit intomainfrom
issue_51
Open

Consolidate three fulfil contact tables into one#52
devinsays wants to merge 1 commit intomainfrom
issue_51

Conversation

@devinsays
Copy link
Copy Markdown
Member

Summary

Closes #51

  • Merges fulfil_contact_metadata, fulfil_broker_contacts, and fulfil_uncategorized_contacts into a single fulfil_contacts table with type and source columns to preserve semantic distinctions
  • Replaces three near-identical models with a single FulfilContact model using query scopes (broker(), discovered(), uncategorized(), etc.)
  • Migration handles data transfer from all three tables and drops the old ones (reversible)

Motivation

All three tables had nearly identical schemas (same fulfil_party_id, email, last_emailed_at, last_received_at) and duplicate model logic (recordEmailSent, recordEmailReceived). GmailService had to query across all three to build a full contact picture. This consolidation simplifies queries, eliminates code duplication, and makes the contact model easier to extend.

Migration notes

  • The migration copies data from all three old tables into fulfil_contacts, then drops them
  • Uses INSERT IGNORE (MySQL) / INSERT OR IGNORE (SQLite) to handle any duplicate (fulfil_party_id, email) pairs across the old tables
  • The down() migration reverses the process if needed

Test plan

  • All 16 ActiveCustomersController tests pass
  • Full test suite passes (157 pass, 3 pre-existing DomPDF failures)
  • Verify migration runs cleanly on production (108 rows in fulfil_contact_metadata, plus broker and uncategorized contacts)
  • Spot-check a customer's contact data after deploy to confirm no data loss

…able (#51)

Merges fulfil_contact_metadata, fulfil_broker_contacts, and fulfil_uncategorized_contacts
into a unified fulfil_contacts table with type and source columns to preserve semantics.
Replaces three near-identical models with a single FulfilContact model using query scopes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate three fulfil contact tables into one

1 participant