Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsMedusa v2’s defineLink connects data models owned by different modules through a separate link table. Medusa’s documentation says that table stores the linked record IDs without database foreign-key constraints. That is a deliberate boundary for cross-module relationships—not evidence that Medusa removed foreign keys from every relationship in an application.
What `defineLink` does
Medusa uses a module link when an application needs to associate data models owned by different modules. Because module isolation prevents one module from directly adding a relationship to another module’s model, the link provides an association without changing the other module’s schema. The link definition lives in the application’s src/links directory and is exported with defineLink. Medusa describes this design in its module links guide.
As an Amazon Associate I earn from qualifying purchases.
For example, a Product model and a custom Blog Post model can be associated through a generated table such as product_product_blog_post, with columns such as product_id and post_id. Medusa states: “These columns store only the IDs of the linked records and do not hold a foreign key constraint.” This applies to the documented module-link table, not every table in a Medusa application.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallA link can also carry information about the association itself. Medusa documents configurable cardinality through isList, query aliases, and custom columns for values such as metadata. Alias configuration is available since Medusa v2.17.2; that version note applies to the alias feature, not the origin of module links.
#1 Best Overall
What changed—and what did not
The phrase “dropped the foreign keys” can suggest a broad schema change. The documented distinction is narrower: Medusa recommends relationships such as hasOne or belongsTo for models within the same module, and module links for models across modules. A same-module relationship can create a foreign-key column. Medusa’s data-model guide, for example, describes an email.user_id column with a foreign key to the user table: Data model relationships.
Medusa’s v2 migration guide frames module isolation as a way to integrate modules without side effects. Its example associates a custom Brand model with Product through a link rather than adding a brand column to Product’s entity. That is the stated architectural rationale, not proof that this pattern prevents every possible side effect: Migrate to Medusa v2.
| Question | Same-module relationship | Cross-module `defineLink` |
|---|---|---|
| Where are the models owned? | Within the same module. | In different modules; the link preserves module isolation. |
| Is there a database foreign key? | A relationship migration can add a foreign-key column; see Medusa’s relationship guide. | The documented link-table ID columns do not have foreign-key constraints, according to Medusa’s module links guide. |
| How is the association represented? | As a relationship between models in the module. | As a separate link table holding linked record IDs. |
What integrity checks does the Link API provide?
The absence of a database foreign key does not mean Medusa documents no checks at all. Its Link API describes cardinality behavior at the application level. Those rules are distinct from constraints enforced by the database engine, and their scope depends on the link type. See Medusa’s Link API reference.
- One-to-one: creating a conflicting second association causes an error.
- One-to-many: the “many” side can link multiple records, while a record on the “one” side cannot be associated with a different record.
- Many-to-many: Medusa says there are no integrity constraints preventing repeated links between the same pair.
That last detail matters when duplicate associations would be invalid for an application: the documented behavior does not promise a duplicate-pair constraint for many-to-many links.
Rank #3
How deletion and restoration work
Do not assume a database ON DELETE action on a module-link table. Medusa documents deletion behavior as part of the link lifecycle: cascade deletion is an explicit link option, and the Link.delete method can remove linked records whose definitions specify cascade deletion when a record is deleted through a workflow or module service. The Link API also documents restoring links for soft-deleted records.
In practice, the application’s deletion and restoration paths need to use the documented link operations and configuration appropriate to the desired behavior. The relevant operations are described in the Link API reference.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How link changes reach a database
For a self-hosted application, Medusa’s module-link guide says to run db:sync-links or db:migrate after adding or changing link definitions. Deployment practices remain relevant: Medusa Cloud’s database guide says deployments run pending database migrations, synchronize links, and then run pending data migration scripts. A self-hosted deployment should follow its own migration procedure. See the Medusa Cloud database guide.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Medusa’s Link guide notes that Remote Link was deprecated in favor of Link as of v2.2.0. This is an API-history note; it does not establish that cross-module links themselves began in that release.
Is `defineLink` a risky tradeoff?
It is a tradeoff in where relationship guarantees come from. The documented benefit is that modules retain ownership of their models while an application can associate their data. The cost is that the generated cross-module link table does not enforce those ID relationships with database foreign keys. Applications therefore need to account for the Link API’s documented cardinality behavior and explicitly configured lifecycle operations in the workflows that create, delete, or restore associations.
Medusa’s official documentation does not provide a benchmark, incident rate, or formal comparison of reliability or performance for this design. The documentation establishes the schema and API behavior above; it does not show that the design causes a measured reliability regression or performance penalty. Whether the tradeoff fits depends on the application’s need for module isolation and where it expects relationship integrity to be enforced.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →




