There is a table of goods ( Goods ). Each product has a price. When creating an order ( Order ) goods are attached to it using the additional Goods__Order table. At the same time, after ordering, the prices of goods in the order should not change, even if they have changed in the Goods table.
One option is to save the price in the Goods__Order table. But the number of fields that should not change may become more, and therefore I don’t want to transfer them all to this table + the option is not very universal.
The second option, as it seems to me, you can log changes in the Goods table to the Goods_audit table, which will contain changes to the fields + version number (revision number). It is available through Hibernate Envers. But then in the Goods_Order table you will need to Goods_Order product id + version number + I did not find examples of what they are doing.
Which option would be better? Given the huge number of online stores, probably already have a more or less well-known solution for this. Yes, and in the options for php no Hibernate Envers.