oroinc / platform

Main OroPlatform package with core functionality.
Other
627 stars 351 forks source link

Error running migrations when upgrading OroCommerce from 4.1.12 to 4.2.5 #1070

Closed AdamJHall closed 3 years ago

AdamJHall commented 3 years ago

Summary
I'm currently in the process of upgrading a project from 4.1.12 CE to 4.2.5 however I'm getting the following when running oro:platform:update

> Oro\Bundle\CheckoutBundle\Migrations\Schema\v1_12\RemoveAlternativeCheckoutWorkflow
    ERROR: An exception occurred while executing 'SELECT e.id FROM oro_checkout e INNER JOIN oro_workflow_item wi ON (CAST(wi.entity_id as integer) = e.id) AND (wi.entity_class = ?) WHERE wi.workflow_name = ?' with params ["Oro\\Bundle\\CheckoutBundle\\Entity\\Checkout", "b2b_flow_alternative_checkout"]:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'integer) = e.id) AND (wi.entity_class = 'Oro\\Bundle\\CheckoutBundle\\Entity\\Ch' at line 1 

This looks to be caused by the cast on line 60 of Oro\Bundle\WorkflowBundle\Migration\RemoveWorkflowAwareEntitiesQuery which I believe for Mysql 8.0 should either be removed or changed to CAST(wi.entity_id as UNSIGNED)

Happy to create a PR to make the change just wanted to confirm it was needed first.

Steps to reproduce

  1. Start with a OroCommerce CE 4.1.12 project
  2. Upgrade to 4.2.5
  3. Perform oro:platform:update

Actual Result Migrations fail with:

> Oro\Bundle\CheckoutBundle\Migrations\Schema\v1_12\RemoveAlternativeCheckoutWorkflow
    ERROR: An exception occurred while executing 'SELECT e.id FROM oro_checkout e INNER JOIN oro_workflow_item wi ON (CAST(wi.entity_id as integer) = e.id) AND (wi.entity_class = ?) WHERE wi.workflow_name = ?' with params ["Oro\\Bundle\\CheckoutBundle\\Entity\\Checkout", "b2b_flow_alternative_checkout"]:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'integer) = e.id) AND (wi.entity_class = 'Oro\\Bundle\\CheckoutBundle\\Entity\\Ch' at line 1 

Expected Result
Migrations complete successfully

Details about your environment

Additional information
Current workaround is to require https://packagist.org/packages/oro/commerce-demo-checkouts so the migration does not run.

AdamJHall commented 3 years ago

Looks like this is a duplicate of: https://github.com/oroinc/orocommerce/issues/131