docs: added missing information on plugin migrations (#12108)

This commit is contained in:
Shahed Nasser
2025-04-07 18:12:25 +03:00
committed by GitHub
parent 83d29c2e79
commit 6c6c3dec9f
3 changed files with 11874 additions and 11830 deletions

View File

@@ -289,18 +289,40 @@ While building those customizations, you can test them in your Medusa applicatio
### Generating Migrations for Modules
During your development, you may need to generate migrations for modules in your plugin. To do that, use the `plugin:db:generate` command:
During your development, you may need to generate migrations for modules in your plugin. To do that, first, add the following environment variables in your plugin project:
```plain title="Plugin project"
DB_USERNAME=postgres
DB_PASSWORD=123...
DB_HOST=localhost
DB_PORT=5432
DB_NAME=db_name
```
You can add these environment variables in a `.env` file in your plugin project. The variables are:
- `DB_USERNAME`: The username of the PostgreSQL user to connect to the database.
- `DB_PASSWORD`: The password of the PostgreSQL user to connect to the database.
- `DB_HOST`: The host of the PostgreSQL database. Typically, it's `localhost` if you're running the database locally.
- `DB_PORT`: The port of the PostgreSQL database. Typically, it's `5432` if you're running the database locally.
- `DB_NAME`: The name of the PostgreSQL database to connect to.
Then, run the following command in your plugin project to generate migrations for the modules in your plugin:
```bash title="Plugin project"
npx medusa plugin:db:generate
```
This command generates migrations for all modules in the plugin. You can then run these migrations on the Medusa application that the plugin is installed in using the `db:migrate` command:
This command generates migrations for all modules in the plugin.
Finally, run these migrations on the Medusa application that the plugin is installed in using the `db:migrate` command:
```bash title="Medusa application"
npx medusa db:migrate
```
The migrations in your application, including your plugin, will run and update the database.
### Importing Module Resources
Your plugin project should have the following exports in `package.json`:

View File

@@ -103,7 +103,7 @@ export const generatedEditDates = {
"app/learn/fundamentals/data-models/check-constraints/page.mdx": "2024-12-06T14:34:50.384Z",
"app/learn/fundamentals/module-links/link/page.mdx": "2025-01-06T09:27:25.604Z",
"app/learn/fundamentals/workflows/store-executions/page.mdx": "2025-02-11T15:56:03.835Z",
"app/learn/fundamentals/plugins/create/page.mdx": "2025-02-12T15:48:25.439Z",
"app/learn/fundamentals/plugins/create/page.mdx": "2025-04-07T14:50:53.866Z",
"app/learn/fundamentals/plugins/page.mdx": "2025-01-22T10:14:10.433Z",
"app/learn/customization/reuse-customizations/page.mdx": "2025-01-22T10:01:57.665Z",
"app/learn/update/page.mdx": "2025-01-27T08:45:19.030Z",

File diff suppressed because it is too large Load Diff