-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
PHP attributes usage cause unexpected changes #9334
Comments
On a Just delete |
Thanks a lot @derrabus you're totally right. Sorry for this issue that is not an issue. |
As an FYI for anyone else who stumbles across here from Google. You also get unexpected changes if you have /**
* @ORM\ManyToMany(targetEntity="App\Entity\Foo")
* @ORM\JoinTable(
* name="bar_foo",
* joinColumns={@ORM\JoinColumn(name="bar_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="foo_id", referencedColumnName="id", unique=true)}
* )
*/ There's a slight note in the Doctrine Attributes Reference:
Hence, to convert this to attributes you need: #[ORM\ManyToMany(targetEntity: Foo::class)]
#[ORM\JoinTable(name: 'bar_foo')]
#[ORM\JoinColumn(name: 'bar_id', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn(name: 'foo_id', referencedColumnName: 'id', unique: true)] In fact, this is the case for all nested annotations. Another example is a UniqueConstraint: /**
* @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(columns={"email"})})
* @ORM\Entity()
*/ Becomes: #[ORM\Table]
#[ORM\UniqueConstraint(columns: ['email'])]
#[ORM\Entity] |
Good news everyone 🙂 Here is clearly described what cases it covers: rectorphp/rector-doctrine#116 (comment), It is now in |
Bug Report
Summary
In a project I try to update from Doctrine Annotations to PHP Attributes, but it causing unexpected schema changes. (Replace the doctrine/migrations#1222)
Current behavior
Previous annotations:
New attributes:
When executing a migrations we have something like:
If I dump fromSchema and toSchema from the Doctrine/Migration DiffGenerator, I have something like:
Before:
After (with attributes):
Expected behavior
By changing from DoctrineAnnotations to PHP Attributes, this change should not appear. This appear 10 times for 51 ManyToMany relations.
The change is always the same, we loose the 'ON DELETE CASCADE' and the constraint name is uppercase.
The text was updated successfully, but these errors were encountered: