diff --git a/www/apps/book/app/advanced-development/modules/module-links/page.mdx b/www/apps/book/app/advanced-development/modules/module-links/page.mdx index 5c09a76363..7f5ebb505f 100644 --- a/www/apps/book/app/advanced-development/modules/module-links/page.mdx +++ b/www/apps/book/app/advanced-development/modules/module-links/page.mdx @@ -60,14 +60,16 @@ The `defineLink` function accepts as parameters the link configurations of each In this example, you define a module link between the `hello` module's `MyCustom` data model and the Product Module's `Product` data model. -### 2. Run Migrations +### 2. Sync Links -Medusa stores links as pivot tables in the database, so you must run migrations after defining a link: +Medusa stores links as pivot tables in the database. So, to reflect your link in the database, run the `links sync` command: ```bash -npx medusa migrations run +npx medusa links sync ``` +Use this command whenever you make changes to your links. For example, run this command if you remove your link definition file. + --- ## Define a List Link diff --git a/www/apps/resources/app/medusa-cli/page.mdx b/www/apps/resources/app/medusa-cli/page.mdx index d4faaa20dc..e5a51d7a68 100644 --- a/www/apps/resources/app/medusa-cli/page.mdx +++ b/www/apps/resources/app/medusa-cli/page.mdx @@ -415,68 +415,36 @@ npx medusa migrations generate -### seed +### links -Runs latest migrations and populates the database with data from a provided JSON file. +Manage module links in the database. ```bash -npx medusa seed --seed-file= +npx medusa links ``` -#### Options +#### Actions + +The `links` command receive an action name as an argument. - Option + Name Description - Required - Default - `-f=`, `--seed-file=` + `sync` - Path to the file holding the data to seed. + Add, update, or delete links based on the definitions in the `src/links` directory of your project. - - - - Yes - - - - - \- - - - - - - - `-m=`, `--migrate=` - - - - - Whether to run migrations before seeding the database. - - - - - No - - - - - `true` - diff --git a/www/apps/resources/app/recipes/marketplace/examples/vendors/page.mdx b/www/apps/resources/app/recipes/marketplace/examples/vendors/page.mdx index 39886ace07..4eff72e195 100644 --- a/www/apps/resources/app/recipes/marketplace/examples/vendors/page.mdx +++ b/www/apps/resources/app/recipes/marketplace/examples/vendors/page.mdx @@ -208,7 +208,7 @@ This adds a list link between the `Vendor` and `Order` data models, indicating t --- -## Step 3: Generate and Run Migrations +## Step 3: Run Migrations and Sync Links To create tables for the marketplace data models in the database, start by generating the migrations for the Marketplace Module with the following command: @@ -218,12 +218,18 @@ npx medusa migrations generate marketplaceModuleService This generates a migration in the `src/modules/marketeplace/migrations` directory. -Then, to reflect the migration and the module links in the database, run the following command: +Then, to reflect the migration in the database, run the following command: ```bash npx medusa migrations run ``` +Next, to reflect your links in the database, run the `links sync` command: + +```bash +npx medusa links sync +``` + --- ## Step 4: Create Vendor Admin Workflow