A
A
Alexander2019-05-02 20:07:19
symfony
Alexander, 2019-05-02 20:07:19

Why can't I validate the Symfony4/Doctr base?

I started a project on symphony2, then updated it to version 3.4, I
need to refactor and rewrite something, I decided to crawl to version 4 on the sly
The project is simple, in principle (I don’t have enough brains for a complex one :((( ), some functionality was added and
for this I am trying to move to version 4, I
ran into a situation that I can’t comprehend
now in the case
- I transferred the entity, the base
changed something I do doctrine:schema:update --force the
doctrine reports that everything is OK, for example 2 queries were executed
but in fact something is not updated
when trying to re-do doctrine:schema:update --force
doctrine again reports that everything is ok - 2 queries were executed
that is - in fact - does not update anything
then this whole economy does not pass validation
swears [ERROR] The database schema is not in sync with the current mapping file.
doctrine:schema:update --dump-sql shows
ALTER TABLE sym4test CHANGE name name VARCHAR(255) DEFAULT NULL;
swears at fields that are nullable=true (if nullable=false then the error disappears, but I need the field to be optional) I
give the entity code below

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="App\Repository\Sym4TestRepository")
 */
class Sym4Test
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $name;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(?string $name): self
    {
        $this->name = $name;

        return $this;
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question