Open khrizt opened 9 months ago
Bug report about a changing the primary key order of a composite primary key when generating new migrations.
Each time I create a migration the same SQL statements appear trying to change the order of a composite primary key.
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:
doctrine-migrations migrations:diff
$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.
The expected behavior would be not creating this SQL statements.
Looks like a bug issue in Doctrine has already been opened: https://github.com/doctrine/orm/issues/9171
Bug Report
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:
Every time
doctrine-migrations migrations:diff
is executed the following code is generated: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.