Skip to content

enum export in model destroys migration #10

@robofinder

Description

@robofinder

i added enum export for status property in my model, that resulted in following error trying to generate migrations:

error: Cannot read properties of undefined (reading 'name') 
TypeError: Cannot read properties of undefined (reading 'name') 
    at Function.className (~/project/medusa-plugin-quotes/node_modules/@mikro-orm/core/utils/Utils.js:627:28)
    at MetadataStorage.get (~/project/medusa-plugin-quotes/node_modules/@mikro-orm/core/metadata/MetadataStorage.js:52:36)
    at MetadataDiscovery.getSchema (~/project/medusa-plugin-quotes/node_modules/@mikro-orm/core/metadata/MetadataDiscovery.js:276:36)
    at MetadataDiscovery.discoverReferences (~/project/medusa-plugin-quotes/node_modules/@mikro-orm/core/metadata/MetadataDiscovery.js:221:33)
    at MetadataDiscovery.findEntities (~/project/medusa-plugin-quotes/node_modules/@mikro-orm/core/metadata/MetadataDiscovery.js:147:14)
    at MetadataDiscovery.discover (~/project/medusa-plugin-quotes/node_modules/@mikro-orm/core/metadata/MetadataDiscovery.js:43:20)
    at MikroORM.discoverEntities (~/project/medusa-plugin-quotes/node_modules/@mikro-orm/core/MikroORM.js:177:46)
    at Function.init (~/project/medusa-plugin-quotes/node_modules/@mikro-orm/core/MikroORM.js:49:19)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async generateMigrations (~/project/medusa-plugin-quotes/node_modules/@medusajs/medusa/src/commands/plugin/db/generate.ts:133:17)

the model:

import { model } from "@medusajs/framework/utils"

export enum QuoteStatus {
  PENDING_MERCHANT = "pending_merchant",
  PENDING_CUSTOMER = "pending_customer",
  ACCEPTED = "accepted",
  CUSTOMER_REJECTED = "customer_rejected",
  MERCHANT_REJECTED = "merchant_rejected",
}

const Quote = model.define("quote", {
  id: model.id().primaryKey(),
  status: model.enum(Object.values(QuoteStatus)).default(QuoteStatus.PENDING_MERCHANT),

})

export default Quote

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions