Objective
I want to disable GeneratedValue of doctrine without updating the entities.
Context
I have two applications, an old one and the new version.
I'm creating a Php script to migrate the data from the old database to the new database.
On the new application there is Doctrine.
Problem
For now I copy paste all my entities each time I do a change on the new application.
But I have to change the Entities to remove the annotations for the auto generted values
* @ORM\GeneratedValue
If I don't the ID won't be se same on the new and the old database.
For example I don't have a user with the ID 500, so when a migrate the users the user supposed to be ID 501 will be 500.
So my first objective is to disable the auto generated, so that when I copy paste the entities I don't have to changes things on it.
Maybe I can change the generation strategy globally ?
$isDevMode = true;
$proxyDir = null;
$cache = null;
$useSimpleAnnotationReader = false;
$config = Setup::createAnnotationMetadataConfiguration(
[PROJECT_ROOT . "/Entities"],
$isDevMode,
$proxyDir,
$cache,
$useSimpleAnnotationReader
);
$queryCache = new ArrayAdapter();
$metadataCache = new ArrayAdapter();
$config->setAutoGenerateProxyClasses(true);
$config->setQueryCache($queryCache);
$config->setMetadataCache($metadataCache);
// database configuration parameters
$conn = [
'url' => 'postgres://user:password@db/database?serverVersion=14.2',
];
// obtaining the entity manager
$entityManager = EntityManager::create($conn, $config);