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
@@ -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`: