# Doctrine\ORM\Mapping\MappingException: Duplicate column definition 'created_at' detected in entity 'App\Entity\Order'

- **ID:** `php/symfony-doctrine-mapping-duplicate-column`
- **Domain:** php
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

A Doctrine entity has two or more properties mapped to the same database column name, often due to inheritance mapping conflicts or copy-paste errors in annotations/attributes.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Doctrine ORM 2.14 | active | — | — |
| Doctrine ORM 2.15 | active | — | — |
| Doctrine ORM 3.0 | active | — | — |

## Workarounds

1. **Inspect the entity and its parent classes for duplicate column definitions. Run `php bin/console doctrine:mapping:info` to list all mapped fields. Then check each property's column attribute: e.g., `#[ORM\Column(name: 'created_at')]` should appear only once. Rename one property's column to something else like 'created_at_utc'.** (90% success)
   ```
   Inspect the entity and its parent classes for duplicate column definitions. Run `php bin/console doctrine:mapping:info` to list all mapped fields. Then check each property's column attribute: e.g., `#[ORM\Column(name: 'created_at')]` should appear only once. Rename one property's column to something else like 'created_at_utc'.
   ```
2. **If using inheritance (e.g., MappedSuperclass), ensure the child class does not override a column from the parent. Use `@ORM\AttributeOverride` to explicitly rename columns in the child: `#[ORM\AttributeOverrides([new ORM\AttributeOverride(name: 'createdAt', column: new ORM\Column(name: 'order_created_at'))])]`** (80% success)
   ```
   If using inheritance (e.g., MappedSuperclass), ensure the child class does not override a column from the parent. Use `@ORM\AttributeOverride` to explicitly rename columns in the child: `#[ORM\AttributeOverrides([new ORM\AttributeOverride(name: 'createdAt', column: new ORM\Column(name: 'order_created_at'))])]`
   ```

## Dead Ends

- **Clearing Doctrine metadata cache with `php bin/console doctrine:cache:clear-metadata`** — The error is in the mapping definition itself, not in a stale cache; clearing cache will not fix duplicate column definitions. (90% fail)
- **Removing all properties that reference 'created_at' from the entity** — This might remove needed functionality; the correct approach is to rename one of the properties or use a different column name. (50% fail)
