0

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?

1
  • 1
    Check serverVersion attribute from DATABASE_URL under .env file to match the MySQL/MariaDB server version. Commented Jun 29 at 11:49

1 Answer 1

2

As @marleen said, try this:

1. Confirm your MariaDB/MySQL version:

SELECT VERSION();

2. Add that version to your Doctrine DSN (.env or config):

DATABASE_URL="mysql://user:[email protected]:3306/dbname?serverVersion=10.11"

(Replace 10.11 with your actual database version!)

3. Clear cache and re-run migrations:

bin/console cache:clear
bin/console make:migration

That’s it!
This prevents Doctrine from looking for columns or system views that don’t exist in your specific database version. If you still run into issues, double-check that the version in your DSN matches the actual DB version, and make sure you don’t have a typo in the URL.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.