Skip to content

Declarative schema: Constraint with type="index" breaks setup process on subsequent upgrades #21304

Open
@k4emic

Description

@k4emic

Preconditions (*)

  1. Magento 2.3

Steps to reproduce (*)

  1. Use <constraint xsi:type="index"... in db_schema.xml
  2. Run setup:upgrade twice

Sample db_schema.xml file

<?xml version="1.0"?>

<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">

    <table name="inventory_source_item">
        <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
                comment="Update Time"/>
        <constraint xsi:type="index" referenceId="INVENTORY_SOURCE_ITEM_UPDATED_AT">
            <column name="updated_at"/>
        </constraint>
    </table>
</schema>

Expected result (*)

  1. Setup process completes with no changes detected

Actual result (*)

  1. Command fails with message PDOException: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'INVENTORY_SOURCE_ITEM_UPDATED_AT'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: SetupIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P4No current plan to fix. Fixing can be deferred as a logical part of more important work.Progress: ready for devReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseSeverity: S4Affects aesthetics, professional look and feel, “quality” or “usability”.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions