E
E
enigma20302021-11-23 11:08:39
symfony
enigma2030, 2021-11-23 11:08:39

Is it possible to create a migration per entity?

Good afternoon.
Example, created 3 entities User, Post, Comment.
If you execute make:migration, then one migration file is created, which reflects all actions with the specified entities.
Is it possible that when a command / function / etc. is called, separate migrations are created for each entity?

https://www.doctrine-project.org/projects/doctrine... did not find any information on this issue

PS https://www.doctrine-project.org/projects/doctrine...

The moral of the story is this: after each change you make to your Doctrine mapping information, run the doctrine:migrations:diff command to automatically generate your migration classes.


It turns out this is the only true option, is it still the creation of a migration after the creation of each entity?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2021-11-23
@myks92

Migration is not grouped by entity change. The only option is to separate the migrations into folders (modules), so that the migrations of one entity fall into the folder and its table instead of the general one.
However, this is required more for modules. I don’t see the point in making migrations for each entity. The task of migrations is to monitor the data schema and change it. There is no point in trying to somehow separate one from the other. It won't do any good.

S
sl0, 2021-11-23
@sl0

Yes, the only option is to migrate after each entity is created. But it doesn't make sense. For example, Post and Comment clearly have a OneToMany relationship. What is the point of spreading them across different migrations?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question