Skip to content

Upgrade from PS 8.1 to 9.0 fails: SQL error when dropping non‑existent index/column #1636

@darkf3d3

Description

@darkf3d3

Prerequisites

Describe the bug and add attachments

When upgrading from PrestaShop 8.x to 9.0 using the autoupgrade module, the upgrade process fails during the database migration step.
The failure occurs because the migration attempts to DROP an index or column (image_type_name) that does not exist in the target database.

This results in a fatal SQL error that stops the upgrade.

Error message
SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'image_type_name'; check that column/key exists

The error is thrown from:

/classes/db/DbPDO.php line 149
/modules/autoupgrade/.../CoreUpgrader.php

Context
The upgrade log shows that the process reaches the migration file for version 9.0.0, and then fails when executing a query that attempts to drop image_type_name from ps_image_type.
However, in many real‑world installations, this index/column may have already been removed.

Expected behavior

Prestashop upgrade module should
Check whether the index or column exists before attempting to drop it
or use DROP INDEX IF EXISTS / DROP COLUMN IF EXISTS (MySQL 8+)
or wrap the operation in a conditional query using information_schema

Steps to reproduce

From a PrestaShop 8.x installation where the table ps_image_type does not contain the index/column image_type_name.
Launch the upgrade to PrestaShop 9.0 using the autoupgrade module.
The upgrade stops during the SQL migration step with error 1091.

PrestaShop version

8.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions