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

Doctrine migrations tries to change the order of composite keys #1366

Open
khrizt opened this issue Oct 16, 2023 · 1 comment
Open

Doctrine migrations tries to change the order of composite keys #1366

khrizt opened this issue Oct 16, 2023 · 1 comment

Comments

@khrizt
Copy link

khrizt commented Oct 16, 2023

Bug Report

Q A
BC Break no
Version 3.5.2

Summary

Bug report about a changing the primary key order of a composite primary key when generating new migrations.

Current behavior

Each time I create a migration the same SQL statements appear trying to change the order of a composite primary key.

How to reproduce

Create an entity with the following mapping:

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                      https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

  <entity name="Entities\ModuleText" table="module_texts">
    <id name="module" association-key="true" />
    <id name="locale" type="string" />
    <many-to-one field="module" target-entity="Entities\Module" inversed-by="texts">
      <join-column name="module_id" referenced-column-name="id" nullable="false" />
    </many-to-one>
    <field name="name" type="string" nullable="false" />
    <field name="description" type="string" nullable="false" />
    <field name="instructions" type="text" nullable="false" />
  </entity>
</doctrine-mapping>

Every time doctrine-migrations migrations:diff is executed the following code is generated:

$this->addSql('DROP INDEX "primary"');
$this->addSql('ALTER TABLE module_texts ADD PRIMARY KEY (locale, module_id)');

Tries to drop the primary key and create a new one switching the field order.

Expected behavior

The expected behavior would be not creating this SQL statements.

@khrizt
Copy link
Author

khrizt commented Oct 16, 2023

Looks like a bug issue in Doctrine has already been opened: doctrine/orm#9171

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

No branches or pull requests

1 participant