Closed
Description
I was following the example in the documentation and durning execution of migration, I got the following error:
Failed to add the foreign key constraint. Missing unique key for constraint 'fk.swag_example_extension.product_id' in the referenced table 'product'
I took closer look at the product
table and realized, that the primary key of this table is not id
, but id, version id
.
So to make the documentation example working I had to do the following things:
- Add additional column in the migration SQL:
`product_version_id` BINARY(16) NOT NULL,
- Modify foreign key in the migration SQL:
CONSTRAINT `fk.swag_example_extension.product_id` FOREIGN KEY (`product_id`, `product_version_id`) REFERENCES `product` (`id`, `version_id`) ON DELETE CASCADE ON UPDATE CASCADE
- Add additional field in the entity definition class:
new ReferenceVersionField(ProductDefinition::class, "product_version_id"),
Metadata
Metadata
Assignees
Labels
No labels