docs: replace usages of migrations and links commands (#8894)
This commit is contained in:
@@ -17,7 +17,7 @@ A migration is a class created in a TypeScript or JavaScript file under a module
|
||||
|
||||
## How to Write a Migration?
|
||||
|
||||
The Medusa CLI tool provides a [migrations generate](!resources!/medusa-cli#migrations-generate) command to generate a migration for the specified modules' data models.
|
||||
The Medusa CLI tool provides a [db:generate](!resources!/medusa-cli/commands/db#dbgenerate) command to generate a migration for the specified modules' data models.
|
||||
|
||||
Alternatively, you can manually create a migration file under the `migrations` directory of your module.
|
||||
|
||||
@@ -51,8 +51,14 @@ In the example above, the `up` method creates the table `my_custom`, and the `do
|
||||
|
||||
To run your migration, run the following command:
|
||||
|
||||
<Note>
|
||||
|
||||
This command also syncs module links. If you don't want that, use the `--skip-links` option.
|
||||
|
||||
</Note>
|
||||
|
||||
```bash
|
||||
npx medusa migrations run
|
||||
npx medusa db:migrate
|
||||
```
|
||||
|
||||
This reflects the changes in the database as implemented in the migration's `up` method.
|
||||
|
||||
@@ -58,14 +58,20 @@ In this example, you define a module link between the `hello` module's `MyCustom
|
||||
|
||||
### 2. Sync Links
|
||||
|
||||
Medusa stores links as pivot tables in the database. So, to reflect your link in the database, run the `links sync` command:
|
||||
Medusa stores links as pivot tables in the database. So, to reflect your link in the database, run the `db:sync-links` command:
|
||||
|
||||
```bash
|
||||
npx medusa links sync
|
||||
npx medusa db:sync-links
|
||||
```
|
||||
|
||||
Use this command whenever you make changes to your links. For example, run this command if you remove your link definition file.
|
||||
|
||||
<Note title="Tip">
|
||||
|
||||
You can also use the `db:migrate` command, which both runs the migrations and syncs the links.
|
||||
|
||||
</Note>
|
||||
|
||||
---
|
||||
|
||||
## Define a List Link
|
||||
|
||||
@@ -51,10 +51,10 @@ A migration defines changes to be made in the database, such as create or update
|
||||
To generate a migration for the data models in your module, run the following command:
|
||||
|
||||
```bash
|
||||
npx medusa migrations generate helloModuleService
|
||||
npx medusa db:generate helloModuleService
|
||||
```
|
||||
|
||||
The `migrations generate` command of the Medusa CLI accepts one or more module names (for example, `helloModuleService`) to generate the migration for.
|
||||
The `db:generate` command of the Medusa CLI accepts one or more module names (for example, `helloModuleService`) to generate the migration for.
|
||||
|
||||
The above command creates a migration file at the directory `src/modules/hello/migrations` similar to the following:
|
||||
|
||||
@@ -81,7 +81,7 @@ In the migration class, the `up` method creates the table `my_custom` and define
|
||||
To reflect the changes in the generated migration file, run the `migration` command:
|
||||
|
||||
```bash
|
||||
npx medusa migrations run
|
||||
npx medusa db:migrate
|
||||
```
|
||||
|
||||
If ran successfully, the `my_custom` table will be created in the database.
|
||||
|
||||
Reference in New Issue
Block a user