Reputation: 21
I am trying to add column to existing table using the format yml.Added the new column entries into .yml file and running the command to generate entity
php app/console doctrine:generate:entities PLibBundle:Contact
By running this getting an error
"No identifier / primary key specified for Entity"
here is my yml file:
Application\PLibBundle\Entity\Contact: type: entity table: null fields: id: type: integer length: null precision: 0 scale: 0 nullable: false unique: false id: true generator: strategy: IDENTITY firstName: type: string length: 255 precision: 0 scale: 0 nullable: false unique: false lastName: type: string length: 255 precision: 0 scale: 0 nullable: false unique: false companyText: type: string length: 255 precision: 0 scale: 0 nullable: true unique: false email: type: string length: 255 precision: 0 scale: 0 nullable: true unique: true hasCustomHeadshot: type: boolean length: null precision: 0 scale: 0 nullable: false unique: false createdOn: type: datetime length: null precision: 0 scale: 0 nullable: false unique: false updatedOn: type: datetime length: null precision: 0 scale: 0 nullable: false unique: false oneToOne: address: targetEntity: Application\PLibBundle\Entity\Address cascade: - remove - persist mappedBy: null inversedBy: null joinColumns: addressId: referencedColumnName: id orphanRemoval: true oneToMany: phoneNumberAssociations: targetEntity: Application\PLibBundle\Entity\ContactPhoneNumberAssociation cascade: - remove - persist mappedBy: contact inversedBy: null orphanRemoval: true orderBy: null subscriptionAssociations: targetEntity: Application\PLibBundle\Entity\ContactSubscriptionAssociation cascade: - remove - persist mappedBy: contact inversedBy: null orphanRemoval: true orderBy: null manyToOne: company: targetEntity: Application\PLibBundle\Entity\Company cascade: { } mappedBy: null inversedBy: null joinColumns: companyId: referencedColumnName: id orphanRemoval: false lifecycleCallbacks: prePersist: - beforePersist preUpdate: - beforeUpdate
Upvotes: 2
Views: 1376
Reputation: 636
You don't have the "id" key in your configuration.
You have:
Application\PLibBundle\Entity\Contact:
type: entity
table: null
fields:
id:
It should be:
Application\PLibBundle\Entity\Contact:
type: entity
table: null
id:
id:
Upvotes: 1
Reputation: 1299
The exception message pretty much solves this mystery, do you have something like this?
Contact:
type: entity
id:
id:
type: integer
generator:
strategy: AUTO
fields:
name:
type: string
length: 100
Upvotes: 4