Doctrine migrations wont recognise changes to annotations (in production)

The original problem

The reasons, notes and members fields bellow where @ORMColumn(type="string", length=20000) which did not work because that is too long for a VARCHAR so I changed them all to @ORMColumn(type="text")

And Now

It is possible that I have misunderstood the correct way to handle migrations in productions but I can’t get my database to match my entity. Running php bin/console doctrine:migrations:diff or php bin/console doctrine:schema:update --dump-sql doctrine tries to update the database to an old version of Request.php like it has been cached but even after running clear-metadata the migrations all say VARCHAR(20000) like in this sql dump after I manually changed the database:

ALTER TABLE request CHANGE reasons reasons VARCHAR(20000) NOT NULL, CHANGE notes notes VARCHAR(20000) DEFAULT NULL, CHANGE members members VARCHAR(20000) NOT NULL;

Current Request.php

namespace AppEntity;

use AppRepositoryRequestRepository;
use DoctrineORMMapping as ORM;
use SymfonyComponentValidatorConstraints as Assert;
/**
 * @ORMEntity(repositoryClass=RequestRepository::class)
 */
class Request
{
    /**
     * @ORMId
     * @ORMGeneratedValue
     * @ORMColumn(type="integer")
     */
    private $id;

    /**
     * @ORMColumn(type="time")
     * @AssertLessThan(propertyPath="endTime", message="The booking must start before it ends")
     */
    private $startTime;

    /**
     * @ORMColumn(type="time")
     */
    private $endTime;

    /**
     * @ORMColumn(type="date")
     */
    private $date;

    /**
     * @ORMColumn(type="text")
     */
    private $reasons;

    /**
     * @ORMColumn(type="text", nullable=true)
     */
    private $notes;

    /**
     * @ORMColumn(type="text")
     */
    private $status;

    /**
     * @ORMManyToOne(targetEntity=User::class, inversedBy="requests")
     * @ORMJoinColumn(nullable=true)
     */
    private $user;

    /**
     * @ORMColumn(type="text")
     */
    private $members;

I have tried removing the Request.php entity but then doctrine gets upset that it is gone. (I do have a relational link to the user table here but it is one to many).

Changing the names of members reasons and notes worked but when I changed the names back it wanted to set them back to VARCHAR(20000). Where is it holding this info. How do I get rid of it?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *