A
A
Alexander2017-03-01 14:38:13
PHP
Alexander, 2017-03-01 14:38:13

Simfony + doctrine creating a table. Why is a varchar field created for a field with the specified integer type?

/**
 * @ORM\Entity{repositoryClass="UrlsRepository"}
 * @ORM\Table{name="app_urlshortener_urls"}
 * @ORM\HasLifecycleCallbacks
 */
 class Urls{
 	/**
   * @ORM\Id()
   * @ORM\Column(name="id", type="integer", nullable=false)
   * @ORM\GeneratedValue{strategy="AUTO"}
   * 
   * @var int
   * 
   */
   protected $id;
   /**
    * @ORM\Column(type="text", nullable=true)
    */
   protected $url;
...

For the id field, I explicitly specify type="integer" in the annotation.
I expect that after app/console doctrine:schema:update --force I will
get an int(11) index field with auto-increment in the mysql table
. Instead, a table is created:
CREATE TABLE `Urls` (
`id` varchar(255) ...
What's wrong with DNA? :(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2017-03-01
@esisl

Mdya...
In the general field became int(11) when generally removed and left:
@ORM\Id
@ORM\Column(type="integer")
@ORM\GeneratedValue
Moreover. I used to have $em->persist crash with an error. And now it's working.
A sorcerer himself, and how I hate all this shamanism!
You can close the question.

A
Alexey Romanenko, 2017-03-06
@slimus

No witchcraft. You have the table name:
@ORM\Table{name="app_urlshortener_urls"}
and the urls table is described elsewhere

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question