db:migrate.
How it works
The Custom Fields module creates a separate table for each entity you extend (e.g.product_custom_fields). Each table is linked back to the original entity via a foreign key with a unique constraint, ensuring a one-to-one relationship. The module automatically registers these links so you can query custom fields through Medusa’s standard remote query.
Configuration
Register the Custom Fields module in yourmedusa-config.ts and define your fields in the customFields option:
medusa-config.ts
customFields (e.g. Product, Customer) must match the entity name as registered in Medusa’s joiner configuration.
After updating your configuration, run migrations to apply the schema changes:
Supported field types
| Type | Description |
|---|---|
string | Short text |
text | Long text |
integer | Whole number |
float | Decimal number |
boolean | True/false |
date | Date only |
time | Time only |
datetime | Date and time |
json | JSON object |
array | Array of values |
enum | One of a predefined set of values (requires enum array) |
Field options
| Option | Type | Default | Description |
|---|---|---|---|
nullable | boolean | true | Whether the field can be null |
defaultValue | any | null | Default value for the field |
enum | string[] | — | Required for enum type. List of allowed values |
Querying custom fields
Custom fields are automatically linked to their parent entity. You can retrieve them using Medusa’s remote query:Using the service directly
The Custom Fields module exposes a service withupsert, delete, and list methods. You can use these in your own workflows and API routes:
upsert method accepts either a single object or an array. If a record already exists for the given entity ID, it updates it; otherwise, it creates a new one.
Workflow steps
The module ships with two workflow steps you can compose into your own workflows:upsertCustomFieldsStep— Takes{ alias, data }wherealiasis the entity name (e.g."product") anddatacontains the entity ID and field values.deleteCustomFieldsStep— Takes{ alias, ids }to soft-delete custom field records by their IDs.