Skip to content
Open
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ by the tool will remove some specific tables and attributes of the Adobe Commerc

**NOTICE**
- This tool has been initially developed for Magento Commerce 2.2.* version.
- This tool is working with latest Adobe Commerce 2.4.* (tested with 2.4.7-p3, thanks to this amazing contributor : [@LucaGallinari](https://github.com/LucaGallinari) [![GitHub followers](https://img.shields.io/github/followers/LucaGallinari.svg?style=social)](https://github.com/LucaGallinari) ❤️)
- This tool is working with latest Adobe Commerce 2.4.* (tested with 2.4.7-p3, thanks to this amazing contributor: [@LucaGallinari](https://github.com/LucaGallinari) [![GitHub followers](https://img.shields.io/github/followers/LucaGallinari.svg?style=social)](https://github.com/LucaGallinari) ❤️)

## How to use

Expand All @@ -25,22 +25,22 @@ Before migrating, change your indexer mode to manual, so the triggers are safely
> - `database` is your magento database
> - `script.sql` is the script you want to run from the following list:

You can use the following [sample](./downgrade.sample).
You can use the following [sample](./downgrade.sample) or generate your own using `cat scripts/*.sql > migrate.sql`.

**READY TO USE:**

- [Attributes](./scripts/attributes.sql)
- [SalesRule](./scripts/salesrule.sql)
- [CatalogRule](./scripts/catalogrule.sql)
- [Category](./scripts/category.sql)
- [Product](./scripts/product.sql)
- [CMS](./scripts/cms.sql)
- [EE Tables](./scripts/ee.sql)
- [Wishlist](./scripts/wishlist.sql)
- [CatalogInventory](./scripts/cataloginventory.sql)
- [Customer](./scripts/customer.sql)
- [Quote](./scripts/quote.sql)
- [Sales](./scripts/sales.sql)
- [Attributes](./scripts/01_attributes.sql)
- [EE Tables](./scripts/02_ee.sql)
- [CMS](./scripts/03_cms.sql)
- [CatalogRule](./scripts/04_catalogrule.sql)
- [SalesRule](./scripts/05_salesrule.sql)
- [Category](./scripts/06_category.sql)
- [Product](./scripts/07_product.sql)
- [CatalogInventory](./scripts/08_cataloginventory.sql)
- [Customer](./scripts/09_customer.sql)
- [Quote](./scripts/10_quote.sql)
- [Sales](./scripts/11_sales.sql)
- [Wishlist](./scripts/12_wishlist.sql)

## Similar package

Expand Down
24 changes: 12 additions & 12 deletions downgrade.sample
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
mysql -u <user> -p<password> <database> < ./scripts/attributes.sql
mysql -u <user> -p<password> <database> < ./scripts/ee.sql
mysql -u <user> -p<password> <database> < ./scripts/cms.sql
mysql -u <user> -p<password> <database> < ./scripts/catalogrule.sql
mysql -u <user> -p<password> <database> < ./scripts/salesrule.sql
mysql -u <user> -p<password> <database> < ./scripts/category.sql
mysql -u <user> -p<password> <database> < ./scripts/product.sql
mysql -u <user> -p<password> <database> < ./scripts/cataloginventory.sql
mysql -u <user> -p<password> <database> < ./scripts/customer.sql
mysql -u <user> -p<password> <database> < ./scripts/quote.sql
mysql -u <user> -p<password> <database> < ./scripts/sales.sql
mysql -u <user> -p<password> <database> < ./scripts/wishlist.sql
mysql -u <user> -p<password> <database> < ./scripts/01_attributes.sql
mysql -u <user> -p<password> <database> < ./scripts/02_ee.sql
mysql -u <user> -p<password> <database> < ./scripts/03_cms.sql
mysql -u <user> -p<password> <database> < ./scripts/04_catalogrule.sql
mysql -u <user> -p<password> <database> < ./scripts/05_salesrule.sql
mysql -u <user> -p<password> <database> < ./scripts/06_category.sql
mysql -u <user> -p<password> <database> < ./scripts/07_product.sql
mysql -u <user> -p<password> <database> < ./scripts/08_cataloginventory.sql
mysql -u <user> -p<password> <database> < ./scripts/09_customer.sql
mysql -u <user> -p<password> <database> < ./scripts/10_quote.sql
mysql -u <user> -p<password> <database> < ./scripts/11_sales.sql
mysql -u <user> -p<password> <database> < ./scripts/12_wishlist.sql
4 changes: 4 additions & 0 deletions scripts/attributes.sql → scripts/01_attributes.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
--
-- 01_attributes.sql
--

-- Remove EE attributes

DELETE
Expand Down
13 changes: 13 additions & 0 deletions scripts/ee.sql → scripts/02_ee.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
--
-- 02_ee.sql
--

-- Drop EE tables

-- ------------------------------------------------------ --
Expand All @@ -7,6 +11,15 @@
-- ------------------------------------------------------ --

SET FOREIGN_KEY_CHECKS = 0;

-- Clean up RMA & Gift Registry table
ALTER TABLE `magento_rma_item_entity`
DROP FOREIGN KEY `MAGENTO_RMA_ITEM_ENTITY_RMA_ENTITY_ID_MAGENTO_RMA_ENTITY_ID`;
ALTER TABLE `magento_giftregistry_entity`
DROP FOREIGN KEY `FK_AC6F6DB40013C09CA44DFBC3453C4954`;
ALTER TABLE `magento_giftregistry_item`
DROP FOREIGN KEY `FK_BAC522E38736441C84A365FDA8A89F3D`;

DROP TABLE IF EXISTS
`catalogpermissions_category_cl`,
`catalogpermissions_product_cl`,
Expand Down
9 changes: 9 additions & 0 deletions scripts/cms.sql → scripts/03_cms.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
--
-- 03_cms.sql
--

update cms_page set creation_time = update_time WHERE `creation_time` LIKE '%0000%';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you uppercase SQL keywords please? (UPDATE + SET)

Also what situation could lead to this one? (a short comment on top of the query is fine)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another that came from the other PR :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should remove this line


-- Enable `block_id` for block store
ALTER TABLE `cms_block_store`
ADD COLUMN `block_id` SMALLINT(6) NOT NULL COMMENT 'Entity ID';
Expand Down Expand Up @@ -55,6 +61,9 @@ ALTER TABLE `cms_block`
MODIFY COLUMN `block_id` SMALLINT(6) NOT NULL AUTO_INCREMENT COMMENT 'Entity ID';
SET FOREIGN_KEY_CHECKS = 1;

-- Clean up any pages we couldn't re-key
DELETE FROM cms_page_store WHERE page_id = 0;
Comment thread
thomas-kl1 marked this conversation as resolved.

-- Update the `page_id` relation link for page store
ALTER TABLE `cms_page_store`
DROP FOREIGN KEY `CMS_PAGE_STORE_ROW_ID_CMS_PAGE_ROW_ID`,
Expand Down
9 changes: 8 additions & 1 deletion scripts/catalogrule.sql → scripts/04_catalogrule.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
--
-- 04_catalogrule.sql
--


-- Enable `rule_id` column for catalogrule

ALTER TABLE `catalogrule_customer_group`
Expand Down Expand Up @@ -61,5 +66,7 @@ ALTER TABLE `catalogrule_website`
-- ----------------
-- Drop sequence --
-- ----------------
-- ALTER TABLE `magento_banner_catalogrule`
-- DROP FOREIGN KEY `MAGENTO_BANNER_CATRULE_RULE_ID_SEQUENCE_CATRULE_SEQUENCE_VAL`;
Comment on lines +69 to +70
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this commented query? The table magento_banner_catalogrule is removed in ee.sql

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or add a short comment on top of it with the reason why


DROP TABLE `sequence_catalogrule`;
DROP TABLE IF EXISTS `sequence_catalogrule`;
58 changes: 58 additions & 0 deletions scripts/salesrule.sql → scripts/05_salesrule.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
--
-- 05_salesrule.sql
--

--
-- This procedure will give you the ability to drop a foreign key if it exists which MySQL/MariaDB can't do on its own.
-- Taken from: https://stackoverflow.com/questions/17161496/drop-foreign-key-only-if-it-exists
--
DROP PROCEDURE IF EXISTS PROC_DROP_FOREIGN_KEY;
DELIMITER $$
CREATE PROCEDURE PROC_DROP_FOREIGN_KEY(IN tableName VARCHAR(64), IN constraintName VARCHAR(64))
BEGIN
IF EXISTS(
SELECT * FROM information_schema.table_constraints
WHERE
table_schema = DATABASE() AND
table_name = tableName AND
constraint_name = constraintName AND
constraint_type = 'FOREIGN KEY')
THEN
SET @query = CONCAT('ALTER TABLE ', tableName, ' DROP FOREIGN KEY ', constraintName, ';');
PREPARE stmt FROM @query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END IF;
END$$
DELIMITER ;



DROP TABLE IF EXISTS
`magento_banner_salesrule`,
`magento_reward_salesrule`,
Expand Down Expand Up @@ -70,6 +100,9 @@ ALTER TABLE `salesrule_product_attribute`
ADD PRIMARY KEY (`rule_id`,`website_id`,`customer_group_id`,`attribute_id`),
DROP COLUMN `row_id`;

-- Clean any orphans
DELETE FROM salesrule_label WHERE rule_id = 0;

-- Label Attribute
ALTER TABLE `salesrule_label`
DROP FOREIGN KEY `SALESRULE_LABEL_ROW_ID_SALESRULE_ROW_ID`,
Expand All @@ -78,6 +111,18 @@ ALTER TABLE `salesrule_label`
DROP COLUMN `row_id`;

-- Salesrule
CALL PROC_DROP_FOREIGN_KEY("salesrule_label", "SALESRULE_LABEL_ROW_ID_SALESRULE_ROW_ID");

-- Amasty related
CALL PROC_DROP_FOREIGN_KEY("amasty_ampromo_rule", "AMASTY_AMPROMO_RULE_SALESRULE_ID_SALESRULE_ROW_ID");
CALL PROC_DROP_FOREIGN_KEY("amasty_amrules_rule", "AMASTY_AMRULES_RULE_SALESRULE_ID_SALESRULE_ROW_ID");
CALL PROC_DROP_FOREIGN_KEY("amasty_amrules_usage_limit", "AMASTY_AMRULES_USAGE_LIMIT_SALESRULE_ID_SALESRULE_ROW_ID");
CALL PROC_DROP_FOREIGN_KEY("amasty_free_gift_timer_timer_data", "AMASTY_FREE_GIFT_TIMER_TIMER_DATA_SALESRULE_ID_SALESRULE_ROW_ID");
CALL PROC_DROP_FOREIGN_KEY("amasty_amrules_usage_counter", "AMASTY_AMRULES_USAGE_COUNTER_SALESRULE_ID_SALESRULE_RULE_ID");
CALL PROC_DROP_FOREIGN_KEY("amasty_banners_lite_banner_data", "AMASTY_BANNERS_LITE_BANNER_DATA_SALESRULE_ID_SALESRULE_RULE_ID");
CALL PROC_DROP_FOREIGN_KEY("amasty_banners_lite_rule", "AMASTY_BANNERS_LITE_RULE_SALESRULE_ID_SALESRULE_ROW_ID");
CALL PROC_DROP_FOREIGN_KEY("amasty_banners_lite_rule", "AMASTY_BANNERS_LITE_RULE_SALESRULE_ID_SALESRULE_RULE_ID");
Comment on lines +116 to +124
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anything related to third party module should be moved to a dedicated file so it's up to anyone to run this one or not (ex: 99_amasty.sql)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your problem there will be that the need running early on so that the products one can run without issue (maybe 00_amasty.sql instead)


ALTER TABLE `salesrule`
DROP FOREIGN KEY `SALESRULE_RULE_ID_SEQUENCE_SALESRULE_SEQUENCE_VALUE`,
DROP COLUMN `row_id`,
Expand All @@ -97,13 +142,26 @@ ALTER TABLE `salesrule_product_attribute`
-- ----------------
-- Drop sequence --
-- ----------------
-- We need to clean up the salesrule_coupon table before dropping the sequence_salesrule table
DELETE FROM salesrule_coupon
WHERE rule_id NOT IN (SELECT rule_id FROM salesrule);

ALTER TABLE `salesrule_coupon`
DROP FOREIGN KEY `SALESRULE_COUPON_RULE_ID_SEQUENCE_SALESRULE_SEQUENCE_VALUE`,
ADD CONSTRAINT `SALESRULE_COUPON_RULE_ID_SALESRULE_RULE_ID` FOREIGN KEY (`rule_id`) REFERENCES `salesrule` (`rule_id`);
ALTER TABLE `salesrule_customer`
DROP FOREIGN KEY `SALESRULE_CUSTOMER_RULE_ID_SEQUENCE_SALESRULE_SEQUENCE_VALUE`,
ADD CONSTRAINT `SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID` FOREIGN KEY (`rule_id`) REFERENCES `salesrule` (`rule_id`);

--
-- Already done above in line 103.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it line 111?

We should regroup the operation over the same table in the same group of queries for more clarity

--
-- ALTER TABLE `salesrule_label`
-- CHANGE `row_id` `rule_id` INT(10) UNSIGNED NOT NULL COMMENT 'Rule ID';

DELETE FROM salesrule_label
WHERE rule_id NOT IN (SELECT rule_id FROM salesrule);

ALTER TABLE `salesrule_label`
ADD CONSTRAINT `SALESRULE_LABEL_RULE_ID_SALESRULE_RULE_ID` FOREIGN KEY (`rule_id`) REFERENCES `salesrule` (`rule_id`);

Expand Down
23 changes: 19 additions & 4 deletions scripts/category.sql → scripts/06_category.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
--
-- 06_category.sql
--

-- Enable `entity_id` column for catalog category entity
DELETE FROM catalog_category_entity WHERE row_id NOT IN (
SELECT tmp_category.row_id FROM (SELECT MAX(row_id) AS row_id FROM catalog_category_entity GROUP BY entity_id) tmp_category
Expand All @@ -19,12 +23,12 @@ ALTER TABLE `catalog_category_entity_varchar`
DELETE e
FROM `catalog_category_entity` e
LEFT OUTER JOIN (
SELECT MAX(`updated_in`) as `last_updated_in`, `entity_id`
SELECT MAX(`updated_at`) as `last_updated_at`, `entity_id`
FROM `catalog_category_entity`
GROUP BY `entity_id`
) AS p
ON e.`entity_id` = p.`entity_id` AND e.`updated_in` = p.`last_updated_in`
WHERE p.`last_updated_in` IS NULL;
ON e.`entity_id` = p.`entity_id` AND e.`updated_at` = p.`last_updated_at`
WHERE p.`last_updated_at` IS NULL;

-- Populate `entity_id` column for catalog category entity

Expand Down Expand Up @@ -131,4 +135,15 @@ ALTER TABLE `catalog_url_rewrite_product_category`
DROP FOREIGN KEY `CAT_URL_REWRITE_PRD_CTGR_CTGR_ID_SEQUENCE_CAT_CTGR_SEQUENCE_VAL`,
ADD CONSTRAINT `CAT_URL_REWRITE_PRD_CTGR_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID` FOREIGN KEY (`category_id`) REFERENCES `catalog_category_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE RESTRICT;

DROP TABLE `sequence_catalog_category`;
--
-- These are already removed by 02_ee.sql
--
-- ALTER TABLE `magento_catalogevent_event`
-- DROP FOREIGN KEY `MAGENTO_CATEVENT_EVENT_CTGR_ID_SEQUENCE_CAT_CTGR_SEQUENCE_VAL`;
-- ALTER TABLE `magento_catalogpermissions`
-- DROP FOREIGN KEY `MAGENTO_CATPERMISSIONS_CTGR_ID_SEQUENCE_CAT_CTGR_SEQUENCE_VAL`;
-- ALTER TABLE `visual_merchandiser_rule`
-- DROP FOREIGN KEY `VISUAL_MERCHANDISER_RULE_CTGR_ID_SEQUENCE_CAT_CTGR_SEQUENCE_VAL`;
--

DROP TABLE IF EXISTS `sequence_catalog_category`;
51 changes: 45 additions & 6 deletions scripts/product.sql → scripts/07_product.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
--
-- 07_product.sql
--

--
-- This procedure will give you the ability to drop a foreign key if it exists which MySQL/MariaDB can't do on its own.
-- Taken from: https://stackoverflow.com/questions/17161496/drop-foreign-key-only-if-it-exists
--
DROP PROCEDURE IF EXISTS PROC_DROP_FOREIGN_KEY;
DELIMITER $$
CREATE PROCEDURE PROC_DROP_FOREIGN_KEY(IN tableName VARCHAR(64), IN constraintName VARCHAR(64))
BEGIN
IF EXISTS(
SELECT * FROM information_schema.table_constraints
WHERE
table_schema = DATABASE() AND
table_name = tableName AND
constraint_name = constraintName AND
constraint_type = 'FOREIGN KEY')
THEN
SET @query = CONCAT('ALTER TABLE ', tableName, ' DROP FOREIGN KEY ', constraintName, ';');
PREPARE stmt FROM @query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END IF;
END$$
DELIMITER ;

-- Enable `entity_id` column for catalog product entity

ALTER TABLE `catalog_product_entity_datetime`
Expand Down Expand Up @@ -288,6 +316,8 @@ ALTER TABLE `catalog_product_bundle_selection`
ADD CONSTRAINT `CAT_PRD_BNDL_SELECTION_OPT_ID_CAT_PRD_BNDL_OPT_OPT_ID` FOREIGN KEY (`option_id`) REFERENCES `catalog_product_bundle_option` (`option_id`) ON DELETE CASCADE ON UPDATE RESTRICT;

ALTER TABLE `catalog_product_bundle_selection_price`
-- DROP INDEX `CATALOG_PRODUCT_BUNDLE_SELECTION_PRICE_WEBSITE_ID`, -- we do not need to remove this index
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a quick explanation?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could remove this line IMO

-- ADD CONSTRAINT `CATALOG_PRODUCT_BUNDLE_SELECTION_PRICE_WEBSITE_ID` FOREIGN KEY (`website_id`) REFERENCES `store_website` (`website_id`) ON DELETE CASCADE ON UPDATE RESTRICT,
ADD CONSTRAINT `FK_DCF37523AA05D770A70AA4ED7C2616E4` FOREIGN KEY (`selection_id`) REFERENCES `catalog_product_bundle_selection` (`selection_id`) ON DELETE CASCADE ON UPDATE RESTRICT;

-- ------------------------------------------------------------------
Expand Down Expand Up @@ -352,18 +382,18 @@ ALTER TABLE `catalog_product_entity_varchar`
ALTER TABLE `catalog_product_entity_media_gallery_value_to_entity`
DROP FOREIGN KEY `CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_ROW_ID_CAT_PRD_ENTT_ROW_ID`,
DROP INDEX `CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_ROW_ID_CAT_PRD_ENTT_ROW_ID`,
ADD CONSTRAINT `CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_VAL_ID_ENTT_ID` UNIQUE KEY (`value_id`,`entity_id`),
DROP PRIMARY KEY,
ADD PRIMARY KEY (`value_id`,`entity_id`),
DROP COLUMN `row_id`;
DROP COLUMN `row_id`,
ADD PRIMARY KEY (`value_id`, `entity_id`),
ADD CONSTRAINT `CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_VAL_ID_ENTT_ID` UNIQUE KEY (`value_id`,`entity_id`);

-- Gallery value
ALTER TABLE `catalog_product_entity_media_gallery_value`
DROP FOREIGN KEY `CAT_PRD_ENTT_MDA_GLR_VAL_ROW_ID_CAT_PRD_ENTT_ROW_ID`,
DROP INDEX `CATALOG_PRODUCT_ENTITY_MEDIA_GALLERY_VALUE_ROW_ID`,
DROP INDEX `CAT_PRD_ENTT_MDA_GLR_VAL_ROW_ID_VAL_ID_STORE_ID`,
DROP INDEX `CAT_PRD_ENTT_MDA_GLR_VAL_ROW_ID_VAL_ID_STORE_ID`,
ADD INDEX `CATALOG_PRODUCT_ENTITY_MEDIA_GALLERY_VALUE_ENTITY_ID` (`entity_id`),
ADD CONSTRAINT `CAT_PRD_ENTT_MDA_GLR_VAL_ENTT_ID_VAL_ID_STORE_ID` UNIQUE KEY (`entity_id`,`value_id`,`store_id`),
ADD INDEX `CAT_PRD_ENTT_MDA_GLR_VAL_ENTT_ID_VAL_ID_STORE_ID` (`entity_id`,`value_id`,`store_id`),
DROP COLUMN `row_id`;

-- Gallery
Expand All @@ -382,7 +412,8 @@ ALTER TABLE `catalog_product_entity_tier_price`
ADD CONSTRAINT `UNQ_E8AB433B9ACB00343ABB312AD2FAB087` UNIQUE KEY (`entity_id`,`all_groups`,`customer_group_id`,`qty`,`website_id`),
DROP COLUMN `row_id`;

-- Entity
-- Entity For some reason, FOREIGN KEY `CAT_PRD_SPR_ATTR_PRD_ID_CAT_PRD_ENTT_ROW_ID was not removed. We need to run it again.
-- ALTER TABLE `catalog_product_super_attribute` DROP FOREIGN KEY `CAT_PRD_SPR_ATTR_PRD_ID_CAT_PRD_ENTT_ROW_ID`;
SET FOREIGN_KEY_CHECKS = 0;
ALTER TABLE `catalog_product_entity`
DROP INDEX `CATALOG_PRODUCT_ENTITY_ENTITY_ID_CREATED_IN_UPDATED_IN`,
Expand Down Expand Up @@ -464,11 +495,13 @@ ALTER TABLE `catalog_product_website`
DELETE c.* FROM `catalog_url_rewrite_product_category` c LEFT JOIN catalog_product_entity p ON c.product_id = p.entity_id WHERE p.entity_id IS NULL;
ALTER TABLE `catalog_url_rewrite_product_category`
DROP FOREIGN KEY `CAT_URL_REWRITE_PRD_CTGR_PRD_ID_SEQUENCE_PRD_SEQUENCE_VAL`,
-- DROP FOREIGN KEY `FK_BB79E64705D7F17FE181F23144528FC8`, -- maybe we have to remove this key instead of the previous one
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was it related to your tests?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that came from the original other PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may depends on builds, sometimes the FK are not generated with the name from the declarative schema (or setup schema)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth wrapping it in the func then, so it can run if it's there, otherwise ignore it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed! but I'm not sure that this key name refer to the same FK (I should browse my projects and check)

ADD CONSTRAINT `CAT_URL_REWRITE_PRD_CTGR_PRD_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE RESTRICT;

DELETE FROM `cataloginventory_stock_item` WHERE `product_id` NOT IN (SELECT `entity_id` FROM `catalog_product_entity`);
ALTER TABLE `cataloginventory_stock_item`
DROP FOREIGN KEY `CATINV_STOCK_ITEM_PRD_ID_SEQUENCE_PRD_SEQUENCE_VAL`,
-- DROP FOREIGN KEY `CATINV_STOCK_ITEM_STOCK_ID_CATINV_STOCK_STOCK_ID`, -- maybe we have to remove this key instead of the previous one
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was it related to your tests?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that came from the original other PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, my bad didn't paid attention to it! it's safe to remove this line, we should'nt remove the relation for the stock ID anyway

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thomas-kl1 no worries :D

ADD CONSTRAINT `CATINV_STOCK_ITEM_PRD_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE RESTRICT;

ALTER TABLE `product_alert_price`
Expand Down Expand Up @@ -507,4 +540,10 @@ ALTER TABLE `wishlist_item`
DROP FOREIGN KEY `WISHLIST_ITEM_PRODUCT_ID_SEQUENCE_PRODUCT_SEQUENCE_VALUE`,
ADD CONSTRAINT `WISHLIST_ITEM_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE RESTRICT;

-- DROP FOREIGN KEY on the sequence table

CALL PROC_DROP_FOREIGN_KEY("magento_targetrule_product", "MAGENTO_TARGETRULE_PRD_PRD_ID_SEQUENCE_PRD_SEQUENCE_VAL");
CALL PROC_DROP_FOREIGN_KEY("email_catalog", "EMAIL_CATALOG_PRODUCT_ID_SEQUENCE_PRODUCT_SEQUENCE_VALUE");
CALL PROC_DROP_FOREIGN_KEY("magento_giftregistry_item", "MAGENTO_GIFTREGISTRY_ITEM_PRD_ID_SEQUENCE_PRD_SEQUENCE_VAL");

DROP TABLE `sequence_product_bundle_selection`,`sequence_product_bundle_option`,`sequence_product`;
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
--
-- 08_cataloginventory.sql
--

ALTER TABLE `cataloginventory_stock_item`
DROP COLUMN `deferred_stock_update`,
DROP COLUMN `use_config_deferred_stock_update`;
4 changes: 4 additions & 0 deletions scripts/customer.sql → scripts/09_customer.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
--
-- 09_customer.sql
--

ALTER TABLE `customer_eav_attribute`
DROP COLUMN `is_used_for_customer_segment`;

Expand Down
5 changes: 5 additions & 0 deletions scripts/quote.sql → scripts/10_quote.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
--
-- 10_quote.sql
--


# These columns are add by these three EE modules: Magento_CustomerBalance, Magento_GiftCardAccount and Magento_GiftRegistry
ALTER TABLE `quote`
DROP COLUMN `customer_balance_amount_used`,
Expand Down
Loading