crmpicco
crmpicco

Reputation: 17181

Gedmo Doctrine mapping restricted to strings - integer not available?

I get the following error when running doctrine:migrations:diff after building a Doctrine mapping file with type of integer.

[Gedmo\Exception\InvalidMappingException] Field - [createdBy] type is not valid and must be 'string' or a reference in class - AyrshireMinis\CourseBundle\Entity\Category

My Category.orm.yml file contains the following:

    createdBy:
        type: string
        gedmo:
            blameable:
                on: create

The intention of this column is that it would represent a user ID, so an integer would make more sense than a VARCHAR(255) which this configuration will produce.

Is there a way to set this as an integer?

Upvotes: 0

Views: 141

Answers (1)

Nawfal Serrar
Nawfal Serrar

Reputation: 2263

It would make more sense if you had a relation between user and category as ManyToOne :

  manyToOne:
    createdBy:
      targetEntity: User
      joinColumn:
        name: created_by
        referencedColumnName: id

Upvotes: 1

Related Questions