Hey team,
I'm facing an issue to extend medusa order model. I want to add some fields in order table without creating new one. I have created model & link for that but facing an error.
order link:
export default defineLink(
{
linkable: CustomOrderModule.linkable.custom_order,
field: 'order_id',
},
OrderModule.linkable.order, // The core Order model
{
readOnly: true, // Use readOnly if you only want to retrieve the linked order
},
);
order model:
const CustomOrder = model.define('custom_order', {
id: model.id().primaryKey(),
orderId: model.text(), // This will be linked to the core Order via a module link
deliveryDate: model.dateTime().nullable(),
warehouseStatus: model
.enum([WarehouseStatus.OPEN, WarehouseStatus.PICKING, WarehouseStatus.SHIPPING, WarehouseStatus.DELIVERED])
.default(WarehouseStatus.OPEN)
.nullable(),
subscriptionBox: model.belongsTo(() => SubscriptionBox),
subscription: model.hasOne(() => Subscription),
});
An error: