ProductAttribute and ProductAttributeValue. Both are defined in packages/core/src/modules/product-attribute/models and resolved through MercurModules.PRODUCT_ATTRIBUTE ("product_attribute"). Like every Medusa data model, each also gets created_at, updated_at, and deleted_at timestamps.
ProductAttribute
A typed attribute in the shared catalog, either global or scoped to one product. Id prefixpattr.
Relations and constraints:
values: has manyProductAttributeValue, deleted with the attributeIDX_product_attribute_handle_unique: uniquehandlewheredeleted_at IS NULL AND handle IS NOT NULLIDX_product_attribute_type: index ontypeIDX_product_attribute_product_id: index onproduct_idwhere it’s not null
ProductAttributeValue
One selectable value of an attribute, or the stored value of atext, unit, or toggle attribute on a product. Id prefix pattrval.
Relations and constraints:
attribute: belongs toProductAttributethroughattribute_idIDX_product_attribute_value_handle_unique: unique(attribute_id, handle)wheredeleted_at IS NULL AND handle IS NOT NULL
AttributeType enum
AttributeType is exported from @mercurjs/types:
Neither model stores which products hold a value. That lives in the
product_attribute_value_link pivot table, described in Links.