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

[4.7] Upgrade events #3675

Draft
wants to merge 2 commits into
base: 4.7
Choose a base branch
from
Draft

[4.7] Upgrade events #3675

wants to merge 2 commits into from

Conversation

lukeholder
Copy link
Member

@lukeholder lukeholder commented Sep 16, 2024

Description

Added the ability to hook into the upgrade command after it has run, but before v3 tables and columns are dropped.

Event Model: \craft\commerce\events\UpgradeEvent
Event: \craft\commerce\console\controllers\UpgradeController::EVENT_BEFORE_DROP_V3_DATABASE_ENTITIES

Event includes the column mapping so previous address IDs can be accessed and migrated by custom module or plugin code:

private array $_v3droppableColumns = [
['table' => '{{%commerce_taxzones}}', 'column' => 'v3isCountryBased'],
['table' => '{{%commerce_shippingzones}}', 'column' => 'v3isCountryBased'],
['table' => '{{%commerce_taxzones}}', 'column' => 'v3zipCodeConditionFormula'],
['table' => '{{%commerce_shippingzones}}', 'column' => 'v3zipCodeConditionFormula'],
['table' => '{{%commerce_orders}}', 'column' => 'v3customerId'],
['table' => '{{%commerce_orders}}', 'column' => 'v3billingAddressId'],
['table' => '{{%commerce_orders}}', 'column' => 'v3shippingAddressId'],
['table' => '{{%commerce_orders}}', 'column' => 'v3estimatedBillingAddressId'],
['table' => '{{%commerce_orders}}', 'column' => 'v3estimatedShippingAddressId'],
['table' => '{{%commerce_customers}}', 'column' => 'v3userId'],
['table' => '{{%commerce_customers}}', 'column' => 'v3primaryBillingAddressId'],
['table' => '{{%commerce_customers}}', 'column' => 'v3primaryShippingAddressId'],
['table' => '{{%commerce_customer_discountuses}}', 'column' => 'v3customerId'],
['table' => '{{%commerce_orderhistories}}', 'column' => 'v3customerId'],
];
private array $_v3tables = [
'{{%commerce_addresses}}',
'{{%commerce_customers_addresses}}',
'{{%commerce_countries}}',
'{{%commerce_states}}',
'{{%commerce_shippingzone_countries}}',
'{{%commerce_shippingzone_states}}',
'{{%commerce_taxzone_countries}}',
'{{%commerce_taxzone_states}}',
];

@lukeholder lukeholder changed the base branch from 5.x to 4.7 September 16, 2024 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant