Migration diff cannot find mapping informations
xavier-rodet opened this issue · 1 comments
Hi,
I try to setup a symfony project with separated domains (each should have it's own db connection, entity managers, entities folder & migrations folder).
My deps:
"doctrine/doctrine-bundle": "^2.7",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.13",
Here is my doctrine.yaml
:
doctrine:
dbal:
connections:
account:
url: '%env(resolve:ACCOUNT_DATABASE_URL)%'
driver: 'pdo_pgsql'
server_version: '14'
charset: utf8
orm:
auto_generate_proxy_classes: true
entity_managers:
account:
connection: account
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
Account:
type: annotation
dir: '%kernel.project_dir%/src/Account/src/Infrastructure/Entity'
prefix: 'Account\Infrastructure\Entity'
alias: Account
I created a separated migration configuration in src/Account/config/packages/doctrine_migrations.yaml
:
migrations_paths:
'DoctrineMigrations': 'src/Account/migrations/'
connection: account
em: account
I created an Entity in src/Account/src/Infrastructure/Entity/Player.php
:
<?php
namespace Account\Infrastructure\Entity;
use Account\Infrastructure\Repository\PlayerRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PlayerRepository::class)]
class Player
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "custom")]
#[ORM\Column(type: "string", length: 36, unique: true, nullable: false)]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
private string $id;
public function setId(string $id): void
{
$this->id = $id;
}
public function getId(): string
{
return $this->id;
}
}
If I try to generate an empty migration file with symfony console doctrine:migrations:generate --configuration src/Account/config/packages/doctrine_migrations.yaml
it does generate an empty migration file in the right folder.
But if i try to generate a migration file from my entities differences with symfony console doctrine:migrations:diff --configuration src/Account/config/packages/doctrine_migrations.yaml
i got this error:
No mapping information to process
What am I missing ?
Thanks
PS: you can try it with my github repository here: https://github.com/xavier-rodet/php-ddd
(you just need to start db with docker compse up
first)
Well it seems my brain has terrible difficulties differencing the words attribute
& annotation
when reading it.
I didn't noticed my configuration was wrong until i debugged the whole doctrine mapping generation code X_X
It works way better with the right configuration (in my case I am using attribute
type for my entities):
doctrine.yaml
:
orm:
auto_generate_proxy_classes: true
entity_managers:
account:
connection: account
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
Account:
type: attribute
dir: '%kernel.project_dir%/src/Account/src/Infrastructure/Entity'
prefix: 'Account\Infrastructure\Entity'
alias: Account
Sometimes I Hate myself =)