Package.json file
{
"name": "my-medusa-plugin",
"version": "1.0.0",
"dependencies": {
"@medusajs/medusa": "2.0.0"
}
}
Node.js version
v20.11.0
Database and its version
PostgreSQL 15
Operating system name and version
Windows 11
Browser name
No response
What happended?
Running npx medusa plugin:db:generate crashes when a model file
exports both a MikroORM entity and a TypeScript enum.
MetadataStorage.getMetadataFromDecorator() returns truthy for
anything with a .name property — which compiled TypeScript enums
have — so enums get misidentified as database entities, causing
MikroORM to crash during migration generation.
Example model file that triggers the bug:
export enum MyStatus {
ACTIVE = "active",
INACTIVE = "inactive",
}
@entity()
export class MyEntity {
@PrimaryKey()
id: string
@enum(() => MyStatus)
status: MyStatus
}
Expected behavior
Migration is generated successfully.
TypeScript enums are ignored during entity detection.
Actual behavior
MikroORM crashes trying to process the enum as a database entity.
The command plugin:db:generate fails completely.
Link to reproduction repo
#14718
Package.json file
{ "name": "my-medusa-plugin", "version": "1.0.0", "dependencies": { "@medusajs/medusa": "2.0.0" } }Node.js version
v20.11.0
Database and its version
PostgreSQL 15
Operating system name and version
Windows 11
Browser name
No response
What happended?
Running
npx medusa plugin:db:generatecrashes when a model fileexports both a MikroORM entity and a TypeScript enum.
MetadataStorage.getMetadataFromDecorator() returns truthy for
anything with a .name property — which compiled TypeScript enums
have — so enums get misidentified as database entities, causing
MikroORM to crash during migration generation.
Example model file that triggers the bug:
export enum MyStatus {
ACTIVE = "active",
INACTIVE = "inactive",
}
@entity()
export class MyEntity {
@PrimaryKey()
id: string
@enum(() => MyStatus)
status: MyStatus
}
Expected behavior
Migration is generated successfully.
TypeScript enums are ignored during entity detection.
Actual behavior
MikroORM crashes trying to process the enum as a database entity.
The command plugin:db:generate fails completely.
Link to reproduction repo
#14718