{
  "id": 9178446,
  "title": "MedusaJS Dropped the Foreign Keys Between Its Modules: The defineLink Gamble",
  "url": "https://urgent.news/2026/09/22/medusajs-dropped-the-foreign-keys-between-its-modules-the-definelink",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-22T18:57:18.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/andriiboyko/medusajs-dropped-the-foreign-keys-between-its-modules-the-definelink-gamble-51mh"
  },
  "original_language": "en",
  "account": "MedusaJS 2.0 has eliminated all foreign keys between its modules, a decision that goes against traditional database practices. This move, known as the \"defineLink gamble,\" aims to increase portability and replaceability of modules within the commerce platform. Each module is self-contained, with its own data models, services, and migrations, and modules are unaware of other modules' resources. To link related models across modules, such as a product and a blog post, a link is defined using a \"linkable\" property in the module's service. When the link is synced, MedusaJS creates a third table with foreign key columns, but these columns do not enforce foreign key constraints. This allows for flexible linking and reading of related records through MedusaJS's Query tool, which can retrieve associated data in a single call.",
  "summary": "MedusaJS 2.0 did something that would get a junior engineer's pull request rejected on sight: it deleted the foreign keys between its own tables. On purpose. Not by accident, not as tech debt, but as the load-bearing decision of the whole architecture. The release notes say it in one flat sentence, and it's worth reading twice: \"We've also eliminated all database-level dependencies, removing…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}