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
I'm trying to create a composite unique key in symfony but this is not present when migration is generated.
Q
A
BC Break
no
Version
2.13
Symfony version
7.2.0
Migration bundle version
3.3
Summary
Current behavior
composite key is missing in the migration file.
How to reproduce
namespace App\Entity;
use App\Repository\LinkRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: LinkRepository::class)]
#[ORM\Table(name: 'link', uniqueConstraints: [
new ORM\UniqueConstraint(name: 'unique_url_source', columns: ['source', 'url'])
])]
class Link
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(options: ['default' => 0])]
private bool $isBroken = false;
#[ORM\Column(type: 'boolean', nullable: false)]
private bool $internal;
#[ORM\Column(type: 'string', length: 255, nullable: false)]
private string $source;
#[ORM\Column(type: 'text', nullable: false)]
private string $url;
#[ORM\Column(nullable: true)]
private ?int $confirmations = null;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
private \DateTimeImmutable $dateDetection;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateUpdated = null;
public function __construct()
{
$this->dateDetection = new \DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function isBroken(): bool
{
return $this->isBroken;
}
public function setBroken(bool $isBroken): static
{
$this->isBroken = $isBroken;
return $this;
}
public function isInternal(): bool
{
return $this->internal;
}
public function setInternal(bool $internal): static
{
$this->internal = $internal;
return $this;
}
public function getSource(): string
{
return $this->source;
}
public function setSource(string $source): static
{
$this->source = $source;
return $this;
}
public function getUrl(): string
{
return $this->url;
}
public function setUrl(string $url): static
{
$this->url = $url;
return $this;
}
public function getConfirmations(): ?int
{
return $this->confirmations;
}
public function setConfirmations(?int $confirmations): static
{
$this->confirmations = $confirmations;
return $this;
}
public function getDateDetection(): \DateTimeImmutable
{
return $this->dateDetection;
}
public function getDateUpdated(): ?\DateTimeInterface
{
return $this->dateUpdated;
}
public function setDateUpdated(?\DateTimeInterface $dateUpdated): static
{
$this->dateUpdated = $dateUpdated;
return $this;
}
}
php bin/console doctrine:migrations:diff
Expected behavior
in migration file, the following line should be present, but is not. $this->addSql('CREATE UNIQUE INDEX unique_url_source ON link (url, source)');
The text was updated successfully, but these errors were encountered:
logosur
changed the title
composite unique keys are not taken in account when create migration
composite unique keys are not taken in account when creating migrations
Dec 9, 2024
Bug Report
I'm trying to create a composite unique key in symfony but this is not present when migration is generated.
Summary
Current behavior
composite key is missing in the migration file.
How to reproduce
php bin/console doctrine:migrations:diff
Expected behavior
in migration file, the following line should be present, but is not.
$this->addSql('CREATE UNIQUE INDEX unique_url_source ON link (url, source)');
The text was updated successfully, but these errors were encountered: