Skip to content

Migrate combination image associations to carry their shop - #1889

Draft
boo-code wants to merge 1 commit into
PrestaShop:devfrom
boo-code:feat/combination-image-shop-column
Draft

Migrate combination image associations to carry their shop#1889
boo-code wants to merge 1 commit into
PrestaShop:devfrom
boo-code:feat/combination-image-shop-column

Conversation

@boo-code

Copy link
Copy Markdown

Migration for PrestaShop/PrestaShop#42190, which gives product_attribute_image the shop its association was made for so that choosing combination images in one shop stops discarding what the other shops chose (PrestaShop/PrestaShop#12638, PrestaShop/PrestaShop#39226).

The new shape mirrors product_carrier: PRIMARY KEY (id_product_attribute, id_image, id_shop).

The order matters, because one existing row becomes one row per shop and the old two column key cannot hold them:

  1. add the column with a temporary default so the existing rows stay valid,
  2. widen the primary key, otherwise the extra rows collide,
  3. give every existing association to each shop its image belongs to, read from image_shop,
  4. drop the placeholder rows and the temporary default.

Existing installs therefore keep exactly the selection they have today: an association becomes visible in the shops that already had the image, and in nothing else.

Verified against a copy of a real 9.2 database with a second shop added and half the images associated to it:

before:  39 rows
after:   57 rows   (39 for shop 1, 18 for shop 2)
leftover id_shop = 0 rows: 0
PRIMARY KEY: id_product_attribute, id_image, id_shop

The INSERT ... SELECT reads through a derived table so MySQL is not selecting from the table it inserts into.

@ps-jarvis

Copy link
Copy Markdown
Collaborator

Hello @boo-code!

This is your first pull request on autoupgrade repository of the PrestaShop project.

Thank you, and welcome to this Open Source community!

@sonarqubecloud

Copy link
Copy Markdown

@boo-code

Copy link
Copy Markdown
Author

Putting this on hold: the core change it migrates, PrestaShop/PrestaShop#42190, has been held for v10 - 9.2.x is under feature freeze and the change is a wide one. Drafting this so it cannot land ahead of the column it migrates to.

The migration itself is unchanged and verified; it will need moving to whichever upgrade file is current when the core side is picked up.

@boo-code
boo-code marked this pull request as draft July 29, 2026 04:45
@Quetzacoalt91 Quetzacoalt91 added the Blocked Status: The issue is blocked by another task label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Blocked Status: The issue is blocked by another task Migration script

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

3 participants