- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
db Commands - Medusa CLI Reference
Commands starting with db:
perform actions on the database.
db:setup#
Creates a database for the Medusa application with the specified name, if it doesn't exit. Then, it runs migrations and syncs links.
It also updates your .env
file with the database name.
Options#
Option | Description | Required | Default |
---|---|---|---|
| The database name. | Yes | - |
| Skip syncing links to the database. | No | Links are synced by default. |
| Skip prompts when syncing links and execute only safe actions. | No | Prompts are shown for unsafe actions, by default. |
| Skip prompts when syncing links and execute all (including unsafe) actions. | No | Prompts are shown for unsafe actions, by default. |
| Disable the command's prompts. | No | - |
db:create#
Creates a database for the Medusa application with the specified name, if it doesn't exit.
It also updates your .env
file with the database name.
Options#
Option | Description | Required | Default |
---|---|---|---|
| The database name. | Yes | - |
| Disable the command's prompts. | No | - |
db:generate#
Generate a migration file for the latest changes in one or more modules.
Arguments#
Argument | Description | Required |
---|---|---|
| The name of one or more module (separated by spaces) to generate migrations for. For example, | Yes |
db:migrate#
Run the latest migrations to reflect changes on the database, and sync link definitions with the database.
Options#
Option | Description | Required | Default |
---|---|---|---|
| Skip syncing links to the database. | No | Links are synced by default. |
| Skip prompts when syncing links and execute only safe actions. | No | Prompts are shown for unsafe actions, by default. |
| Skip prompts when syncing links and execute all (including unsafe) actions. | No | Prompts are shown for unsafe actions, by default. |
db:rollback#
Revert the last migrations ran on one or more modules.
Arguments#
Argument | Description | Required |
---|---|---|
| The name of one or more module (separated by spaces) to rollback their migrations for. For example, | Yes |
db:sync-links#
Sync the database with the link definitions in your application, including the definitions in Medusa's modules.
Options#
Option | Description | Required | Default |
---|---|---|---|
| Skip prompts when syncing links and execute only safe actions. | No | Prompts are shown for unsafe actions, by default. |
| Skip prompts when syncing links and execute all (including unsafe) actions. | No | Prompts are shown for unsafe actions, by default. |