I need some help regarding the usage of Doctrine Translatable (from Doctrine Extensions)
Context
I use Doctrine Translatable to translate an entity, and my use-case follows closely this example from the docs.
This approach, where the translation entity extends AbstractPersonalTranslation
, leads to a translation table having an ID generation with strategy “IDENTITY”, because AbstractPersonalTranslation is as follows:
...
#[ORMMappedSuperclass]
abstract class AbstractPersonalTranslation
{
#[ORMColumn(type: Types::INTEGER)]
#[ORMId]
#[ORMGeneratedValue(strategy: 'IDENTITY')]
protected $id;
...
The issue
The fact is that, for reasons that I explain at the end of the post, I want to change the definition of the GeneratedValue strategy for my translation table extending AbstractPersonalTranslation
.
What I have tried
I tried overriding the property as follows in my child class:
class MyEntityTranslation extends AbstractPersonalTranslation
{
#[ORMColumn(type: Types::INTEGER)]
#[ORMId]
#[ORMGeneratedValue(strategy: 'SEQUENCE')]
protected $id;
...
however I get the following error:
In MappingException.php line 420:
Duplicate definition of column 'id' on entity 'AppEntityTranslationDeviceNotificationTranslation' in a field or discriminator column mapping.
Why do I want to do this?
This is probably not relevant for the issue but the reason why I need to change the auto-generated ID strategy is because I am currently upgrading my project ot Doctrine’s ORM 3 and DBAL 4 with a PostgreSQL DB, which changes the default strategy. I would like to deploy the upgrade without changing my DB tables and, afterwards, perform the migration of the DB IDs (as suggested by some important contributors)