K
K
kosuha2017-10-29 15:09:10
symfony
kosuha, 2017-10-29 15:09:10

How to regenerate ID for Symfony2\3 entities?

Hello!
There is an existing not big table with services. It turned out that I need to synchronize this table with a service that has all IDs in GUID format, and my tables just have auto-increment numbers.
Is it possible to use doctrine to go through all the records in the table and convert all id's from numbers to new UUID(GUID)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Talalaev, 2017-10-29
@kosuha

In any case, you need migration , but in general the problem is not so terrible, I would not delete the current id if there is no requirement that the field name should be like this, maybe you need it for internal purposes? if not. In principle, you can write a competent migration. Since you are writing about synchronization with the service, then in general it is not even necessary to drop the current table if all its contents are synchronized?
But even so, just a little more code in the migration.
If you still decide to delete your id, then you need to remember about dependent tables where this id is used for links, then you need to correctly take into account everything and everyone.
Migrations are a convenient tool for both creating and modifying tables, so it allows you to roll back if necessary to one of the previous versions. Must have in any project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question