docs: general fixes across documentation (#4248)
* docs: added details about the migration revert command * added a note about running postgres before the backend * added a link to typeorm's documentation * fix broken links * fixed section title * fixed admonitions
This commit is contained in:
@@ -177,6 +177,12 @@ await postRepository.softDelete(post.id)
|
||||
|
||||
---
|
||||
|
||||
## Advanced Entity Definitions
|
||||
|
||||
With entities, you can create relationships, index keys, and more. As Medusa uses Typeorm, you can learn about using these functionalities through [Typeorm's documentation](https://typeorm.io/).
|
||||
|
||||
---
|
||||
|
||||
## See Also
|
||||
|
||||
- [Extend Entity](./extend-entity.md)
|
||||
|
||||
@@ -202,3 +202,9 @@ You can also add custom relations by changing the following defined variables:
|
||||
- `defaultStoreProductsRelations`: The relations of a product that are retrieved and returned by default in the product's store endpoints.
|
||||
|
||||
If you want to apply this example for a different entity or set of endpoints, you would need to change the import path `@medusajs/medusa/dist/api/routes/store/products/index` to the path of the endpoints you're targeting. You also need to change `allowedStoreProductsFields` and `defaultStoreProductsFields` to the names of the variables in that file, and the same goes for relations. Typically, these names would be of the format `(allowed|default)(Store|Admin)(Entity)(Fields|Relation)`.
|
||||
|
||||
---
|
||||
|
||||
## Advanced Entity Definitions
|
||||
|
||||
With entities, you can create relationships, index keys, and more. As Medusa uses Typeorm, you can learn about using these functionalities through [Typeorm's documentation](https://typeorm.io/).
|
||||
|
||||
@@ -90,7 +90,7 @@ npm run build
|
||||
The last step is to run the migration with the command detailed earlier
|
||||
|
||||
```bash
|
||||
medusa migrations run
|
||||
npx @medusajs/medusa-cli migrations run
|
||||
```
|
||||
|
||||
If you check your database now you should see that the change defined by the migration has been applied successfully.
|
||||
|
||||
@@ -25,16 +25,14 @@ Migrations are used to apply changes to the database schema. However, there are
|
||||
|
||||
---
|
||||
|
||||
## How to Run Migrations
|
||||
|
||||
Migrations in Medusa can be done in one of two ways:
|
||||
## Migration Commands
|
||||
|
||||
### Migrate Command
|
||||
|
||||
Using the Medusa CLI tool, you can run migrations with the following command:
|
||||
|
||||
```bash
|
||||
medusa migrations run
|
||||
npx @medusajs/medusa-cli migrations run
|
||||
```
|
||||
|
||||
This will check for any migrations that contain changes to your database schema that aren't applied yet and run them on your backend.
|
||||
@@ -46,10 +44,22 @@ Seeding is the process of filling your database with data that is either essenti
|
||||
You can use the following command to seed your database:
|
||||
|
||||
```bash npm2yarn
|
||||
npm run seed
|
||||
npx @medusajs/medusa-cli@latest seed -f ./data/seed.json
|
||||
```
|
||||
|
||||
This will use the underlying `seed` command provided by Medusa's CLI to seed your database with data from the file `data/seed.json` on your Medusa backend.
|
||||
This assumes that you have the file `data/seed.json` in your Medusa backend, which is available by default. It includes the demo data to seed into your database.
|
||||
|
||||
### Revert Migrations
|
||||
|
||||
To revert the last migration you ran, run the following command:
|
||||
|
||||
```bash
|
||||
npx @medusajs/medusa-cli@latest migrations revert
|
||||
```
|
||||
|
||||
### Other Migrations Commands
|
||||
|
||||
You can learn about migration commands available in the Medusa CLI tool by referring to the [Medusa CLI reference](../../../cli/reference.md#migrations)
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user