autocustomergroup
autocustomergroup copied to clipboard
Compatibility issue M2.3/M2.4 and DB engine - column definition "order_id" / "entity_id" are different
Running setup:upgrade
, on the below mentioned environment, throws following output and breaks when upgrading modules:
Column definition "order_id" and reference column definition "entity_id" are different in tables "sales_order_tax_scheme" and "sales_order"
Environment encountered on :
- Magento 2.3.7-p4
- mysql Ver 15.1 Distrib 10.3.38-MariaDB
- PHP 7.4.33
Debug findings by dumping from vendor/magento/framework/Setup/Declaration/Schema/Declaration/ValidationRules/IncosistentReferenceDefinition.php:assertDefinitionEqual()
checks:
assertUnassigned: bool(true)
assertIntegerEquals: bool(false)
assertStringBinariesEqual: bool(true)
column getPadding = 11
referenceColumn getPadding = 10
BTW: this method/file also contained another bug that is present until M2.4.3: https://github.com/magento/magento2/issues/32309
So it all comes down to this M2.3/M2.4 change noticed here: https://magento.stackexchange.com/questions/330646/declarative-schema-uses-padding-in-2-3-gone-in-2-4-do-we-have-to-use-it
For the moment, I 'fixed' it by adding padding="10"
into db_schema.xml
:
<column xsi:type="int" name="order_id" unsigned="true" nullable="false" identity="false" padding="10"
comment="Order ID"/>
but I don't know if this would break on environments with MySQL8 or MariaDB10.4 as hinted by the core changing commit title: https://github.com/magento/magento2/commit/159b377cd29be55c8d3af75f0cd5ba731a21b3c3
Thanks for bringing this to my attention, I was unaware of the incompatability.
Thanks for investigating so thoroughly.
I'm not really sure what to do with this one, as it would seem to be incompatible with the current releases.
I'll just leave the issue open, so that if others run into the problem, they can see the workaround.
Thanks again.