Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Solved error while upgrading from 2.1 to 2.2 #11735

Merged

Conversation

lewisvoncken
Copy link
Contributor

Same as #11651

Given error while running setup:upgrade:

`postcode is a required field`

Problem is solved by setting tax_postcode to * if it was NULL

Description

When you try to upgrade from 2.1 to 2.2 and you have the following two tax rates in your 2.1 installation:

Rate 1:

  • tax_calculation_rate_id = 1
  • tax_country_id = US
  • tax_region_id = 43
  • tax_postcode = NULL
  • code = US-CA-*-Rate 1
  • rate = 8.25
  • zip_is_range = NULL
  • zip_from = NULL
  • zip_to = NULL

Rate 2:

  • tax_calculation_rate_id = 5
  • tax_country_id = US
  • tax_region_id = 12
  • tax_postcode = NULL
  • code = US-NY-*-Rate 1
  • rate = 8.3750
  • zip_is_range = NULL
  • zip_from = NULL
  • zip_to = NULL

Insert query for these rates is:

INSERT INTO `tax_calculation_rate` (`tax_calculation_rate_id`, `tax_country_id`, `tax_region_id`, `tax_postcode`, `code`, `rate`, `zip_is_range`, `zip_from`, `zip_to`) VALUES (1, 'US', 12, NULL, 'US-CA-*-Rate 1', 8.2500, NULL, NULL, NULL), (5, 'US', 43, NULL, 'US-NY-*-Rate 1', 8.3750, NULL, NULL, NULL)

Fixed Issues (if relevant)

  1. Magento_Tax "postcode is a required field" when upgrading from 2.1.9 to 2.2 #11095: Magento_Tax "postcode is a required field" when upgrading from 2.1.9 to 2.2

Manual testing scenarios

  1. Insert or change rules so they are the same as the above rates
  2. Set setup_module version Magento_Tax from 2.0.2 to 2.0.1 (this will simulate an upgrade from M2.1 to M2.2 for the Magento_Tax module)
  3. Run setup:upgrade and the error is given

Apply changes and the data will be changed automatically and this manual query is no longer needed:

UPDATE tax_calculation_rate SET tax_postcode = '*' WHERE tax_postcode IS NULL

tax_calculation_rate table before:
image

tax_calculation_rate table after:
image

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@orlangur orlangur self-assigned this Oct 25, 2017
@orlangur orlangur added this to the October 2017 milestone Oct 25, 2017
@TomashKhamlai
Copy link
Contributor

TomashKhamlai commented Oct 30, 2017

Hello @lewisvoncken.
It looks to me that the issue is present after the fix is applied. I will show you, what I am doing just to check that we perform the same actions.

Steps to reproduce:

  1. Clone Magento where the fix is applied
  2. Update taxes and change Magento_Tax module version:
SELECT * FROM tax_calculation_rate;
UPDATE tax_calculation_rate SET tax_postcode=NULL WHERE tax_calculation_rate_id=1;
UPDATE tax_calculation_rate SET tax_postcode=NULL WHERE tax_calculation_rate_id=2;
SELECT * FROM setup_module where module='Magento_Tax';
UPDATE setup_module SET data_version='2.0.1' WHERE module='Magento_Tax';
UPDATE setup_module SET schema_version='2.0.1' WHERE module='Magento_Tax';
  1. Upgrade:
php bin/magento index:reindex && php bin/magento cache:flush && php bin/magento setup:upgrade

Expected result:

...
Nothing to import

Actual result:

...
Module 'Magento_Tax':
Upgrading data.. postcode is a required field.

Please, correct me if there is something missing here.

@lewisvoncken
Copy link
Contributor Author

@TomashKhamlai and @orlangur

I have just run the given scenario and if you apply the changes you will successfully go from 2.0.1 to 2.0.3 of the Magento_Tax module and the outcome of setup:upgrade is Nothing to Import

Tables Before:
image
image

Table After
image

image

Result:
image

In the above example I have just the query as you provided.

@okorshenko okorshenko modified the milestones: October 2017, November 2017 Nov 1, 2017
@orlangur orlangur added Fixed in 2.2.x The issue has been fixed in 2.2 release line Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release labels Nov 27, 2017
@magento-team magento-team merged commit 099ea6b into magento:2.3-develop Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Progress: accept Release Line: 2.3 Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants