JOB-EASY

Global Companies

The community-sourced, automatically deduplicated company directory.

Users maintain private Company lists, typically populated via CSV upload. During upload, they can opt-in to share their companies with the community. When they do, a distinct GlobalCompany record is created.

This is deliberately NOT a view over the Company table. If a user deletes their account, their private Company rows are cascade-deleted, but the GlobalCompany rows survive—only the contributedById is set to null.

Deduplication Probes

To prevent the global pool from filling with duplicates of "Google" or "Amazon", the system uses a 4-branch deduplication probe:

  • Email: Match exactly on emailKey.
  • Phone: Match exactly on phoneKey.
  • Domain: The registrable host of the website (e.g., amazon.com). Bypassed for free-mail or ATS domains.
  • Name + Location: A fallback match on nameKey and locationKey. Matching a bare name globally would incorrectly merge unrelated same-named companies.

If a match is found, the existing row's contributionCount is bumped instead of inserting a new row.

pg_trgm for Fast Search

Users can search the global pool by partial names or locations. Because standard B-Trees cannot index a leading wildcard search (e.g., %dubai%), we manually install the pg_trgm extension via a raw SQL migration and index the locationTokens column.

prisma/migrations/20260721000000_init/migration.sql
-- Required for the GIN index on GlobalCompany.locationTokens
CREATE EXTENSION IF NOT EXISTS pg_trgm;

CREATE INDEX "GlobalCompany_locationTokens_idx" 
ON "GlobalCompany" USING GIN ("locationTokens" gin_trgm_ops);