Skip to content

Refactor: remove Profile intermediate entity from Deal — move criteria joins directly onto Deal #474

@nadavosa

Description

@nadavosa

Background

The current model has a Profile entity sitting between Deal and the actual criteria objects:

Deal → Profile → ProfileActivity → Activity
                → ProfileLanguage → Language
                → ProfileSkill   → Skill
                → Category (optional)
                .info (optional string)

Both Opportunity and Volunteer inherit their shared criteria (languages, activities, skills) by navigating entity.deal.profile.*. The Profile entity was likely introduced to allow criteria reuse across multiple Deals (the schema allows one Profile to be referenced by many Deals), but in practice each Deal appears to have its own Profile — making it over-engineered.

Proposed Change

Remove Profile and collapse its M2M relationships directly onto Deal:

Deal → DealActivity → Activity
     → DealLanguage → Language
     → DealSkill    → Skill

The profile.info and profile.category fields would need a new home — likely directly on Deal, or split to Opportunity / Volunteer depending on which actually uses them.

Impact Areas to Audit Before Making Changes

Before touching any code, the following must be scanned:

  • All services/repositories that query or write deal.profile (profile loading, eager joins)
  • All DTOs / response types that expose profile fields in API responses
  • All controller endpoints that accept or return profile-shaped data
  • FE API calls and types that reference profile — see https://github.com/need4deed-org/fe
  • Any seed data or fixtures that create Profile records
  • Migrations — new join tables (deal_activity, deal_language, deal_skill) must be created and old profile_activity, profile_language, profile_skill data migrated before dropping profile
  • The category relationship currently on Profile — decide where it moves
  • The profile.info field — decide where it moves

Acceptance Criteria

  • Profile, ProfileActivity, ProfileLanguage, ProfileSkill entities are removed
  • Deal directly exposes activity, language, and skill M2M relationships
  • All existing data is migrated without data loss
  • No API response shape changes that break the FE without a coordinated FE update
  • All tests pass

Notes

  • This is a breaking change to the API response shape — coordinate with the FE team before merging
  • Do NOT add migration columns/tables until the approach above is agreed upon

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions