I am learning Symfony and trying to create a simple API. I have defined two Doctrine entities, GameGenre and Game. Here are their codes: This is my GameGenre Entity: <?php
namespace App\Entity;
use App\Repository\GameGenreRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: GameGenreRepository::class)]
#[ORM\HasLifecycleCallbacks]
class GameGenre
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private string $name;
#[ORM\Column(type: "datetime")]
private \DateTimeInterface $createdAt;
#[ORM\Column(type: "datetime")]
private \DateTimeInterface $updatedAt;
public function __construct(string $name)
{
$this->name = $name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getCreatedAt(): \DateTimeInterface
{
return $this->createdAt;
}
public function getUpdatedAt(): \DateTimeInterface
{
return $this->updatedAt;
}
#[ORM\PrePersist]
public function onPrePersist(): void
{
$this->createdAt = new \DateTimeImmutable();
$this->updatedAt = new \DateTimeImmutable();
}
#[ORM\PreUpdate]
public function onPreUpdate(): void
{
$this->updatedAt = new \DateTimeImmutable();
}
}
This is my Game Entity: <?php
namespace App\Entity;
use App\Repository\GameRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: GameRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Game
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private int $id;
#[ORM\Column(length: 255)]
private string $name;
#[ORM\ManyToOne(targetEntity: GameGenre::class)]
#[ORM\JoinColumn(nullable: false)]
private GameGenre $genre;
#[ORM\Column(type: "datetime")]
private \DateTimeInterface $createdAt;
#[ORM\Column(type: "datetime")]
private \DateTimeInterface $updatedAt;
public function getId(): ?int
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getGenre(): GameGenre
{
return $this->genre;
}
public function setGenre(GameGenre $genre): static
{
$this->genre = $genre;
return $this;
}
public function getCreatedAt(): \DateTimeInterface
{
return $this->createdAt;
}
public function getUpdatedAt(): \DateTimeInterface
{
return $this->updatedAt;
}
#[ORM\PrePersist]
public function onPrePersist(): void
{
$this->createdAt = new \DateTimeImmutable();
$this->updatedAt = new \DateTimeImmutable();
}
#[ORM\PreUpdate]
public function onPreUpdate(): void
{
$this->updatedAt = new \DateTimeImmutable();
}
}
When I try to run the migration command: php bin/console make:migration
I get that error:
[critical] Error thrown while running command "make:migration". Message: "An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ccsa.FULL_COLLATION_NAME' in 'on clause'"
In ExceptionConverter.php line 67:
An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ccsa.FULL_COLLATION_NAME' in 'on cl
ause'
In Exception.php line 24:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ccsa.FULL_COLLATION_NAME' in 'on clause'
In Statement.php line 130:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ccsa.FULL_COLLATION_NAME' in 'on clause'
make:migration [--formatted] [--configuration [CONFIGURATION]]
What can cause it and how can I fix it?