You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During the upgrade from php 7.4 to php 8.1 (same DB server, with same database_url, from sf 5.4 to 6.4), I have a break while converting Annotation to Attribute: does not work for ORM\UniqueConstraint.
Note: My application extend the user (utilisateur) class from my custom bundle (it is an important detail as we will see in the end):
This code would produce this migration (php bin/console make:migration):
// ...publicfunctionup(Schema$schema): void
{
// this up() migration is auto-generated, please modify it to your needs// ...$this->addSql('CREATE UNIQUE INDEX UNIQ_1D1C63B3C90409EC ON utilisateur (identifiant) WHERE est_actif = true');
// ...
}
Current behavior
With attributs, now the code produces this migration (php bin/console make:migration):
// ...publicfunctionup(Schema$schema): void
{
// this up() migration is auto-generated, please modify it to your needs$this->addSql('CREATE UNIQUE INDEX UNIQ_1D1C63B3C90409EC ON "utilisateur" (identifiant)');
// ...
}
How to reproduce
In my class user I tried 2 way to write the UniqueConstraint:
Note: If I update the child class 'user' (utilisateur) it will work as the following code shows, BUT, I need my bundle to works for all apps using MyBundle:
<?phpnamespaceApp\Entity;
useDoctrine\ORM\MappingasORM;
useMy\MyBundle\Entity\UtilisateurasBaseUtilisateur;
#[ORM\Table(name: '`utilisateur`')]
#[ORM\Entity(repositoryClass: \App\Repository\UtilisateurRepository::class)]
#[ORM\UniqueConstraint(
name: 'uniq_identifiant_actif', // here I added a name, or it will conflict with parent constraint, i just want to check what happend if i created a constraint here for the science
columns: ['identifiant'],
options: ['where' => 'est_actif = true']
)]
classUtilisateurextendsBaseUtilisateur
{
}
And the migration created:
// ...publicfunction up(Schema$schema): void
{
// this up() migration is auto-generated, please modify it to your needs$this->addSql('CREATE UNIQUE INDEX UNIQ_1D1C63B3C90409EC ON "utilisateur" (identifiant)'); // this comes from the is the attribut of the parent user class: FAIL $this->addSql('CREATE UNIQUE INDEX uniq_identifiant_actif ON "utilisateur" (identifiant) WHERE est_actif = true'); // this comes from the attribute of the child user class: SUCCESS
This suggest myBundle can't hold the description of the user entity of all my apps using the bundle.
It looks like all the apps using the same bundle must explicitly tells ORM how to migrate correctly the constraint (why would i create a bundle to extend the parent class then?)
Do you confirm there is a break/regression here, or it is something else?
Any hint welcome !
thanks
The text was updated successfully, but these errors were encountered:
BC Break Report
Summary
During the upgrade from php 7.4 to php 8.1 (same DB server, with same database_url, from sf 5.4 to 6.4), I have a break while converting Annotation to Attribute: does not work for
ORM\UniqueConstraint
.Note: My application extend the user (utilisateur) class from my custom bundle (it is an important detail as we will see in the end):
Previous behavior
This code would produce this migration (
php bin/console make:migration
):Current behavior
With attributs, now the code produces this migration (
php bin/console make:migration
):How to reproduce
In my class user I tried 2 way to write the UniqueConstraint:
ORM
to be more "compliant" with the documentation:According to the documentation, the parameter
field
is required, so I added it, still produce the not expected migrationI explicitly told doctrine to use attibutes:
Note: If I update the child class 'user' (utilisateur) it will work as the following code shows, BUT, I need my bundle to works for all apps using MyBundle:
And the migration created:
This suggest myBundle can't hold the description of the user entity of all my apps using the bundle.
It looks like all the apps using the same bundle must explicitly tells ORM how to migrate correctly the constraint (why would i create a bundle to extend the parent class then?)
Do you confirm there is a break/regression here, or it is something else?
Any hint welcome !
thanks
The text was updated successfully, but these errors were encountered: