CodelyTV / php-ddd-example

🐘🎯 Hexagonal Architecture + DDD + CQRS in PHP using Symfony 7
https://pro.codely.tv/library/ddd-en-php
2.98k stars 1.08k forks source link

Question: Databases creation procedure. #131

Closed Axxon closed 4 years ago

Axxon commented 4 years ago

https://github.com/CodelyTV/php-ddd-example/blob/4a6840dd8926cc42e05362a613d4084eafefd0ca/src/Shared/Infrastructure/Doctrine/DoctrineEntityManagerFactory.php#L33

Hello, and first, thanks you to sharing this project, you made a great job. I'm trying to figure out why a raw sql mapping is used instead of directly using the mapping of entities (*.orm.xml). Could you explain it to me please. It make sense for performance, for the tests (initialisation time) ? or for more granular definition of database ? I'm trying now to use the xml mapping first (at place of EntityManagerFactory::generateDatabaseIfNotExists) but it seems to be a headache mission.

rgomezcasas commented 4 years ago

We have some courses where we explain it, but those are in Spanish 😳.

A summary of this will be: We prefer to be explicit in the database schema creating, so we don't rely on the ORM for it. Also, if we "control" this creating, we can follow our convention in the schemas (upper o lower cases, indexes names...). And it's also faster in testing for recreating this environment :)

Regards!