如何更改实体中的数据库列类型

问题描述 投票:-2回答:1

我想将colum的类型从int更改为string。我在我的实体文件中更改它,但是当我发出make:migration后跟doctrine:migrations:migrate它不起作用。如何从实体更新dB字段类型?

也许我是愚蠢但我试图寻找无济于事

这是我的实体的一部分:

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

/**
 * @ORM\Entity(repositoryClass="App\Repository\RideRepository")
 * @UniqueEntity(fields={"strava_ride_id"}, message="There is already a ride with this ID", ignoreNull=true)
 */

class Ride
{
    /**
     * @ORM\Column(type="integer", nullable=true)
     */
     private $strava_ride_id;

我想将其更改为:

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

但是当我跑步时没有任何反应:

php bin/console doctrine:migrations:diff

要么

 php bin/console make:migration  

我试过清除缓存:

 php bin/console doctrine:cache:clear-metadata 

谢谢

马丁

symfony
1个回答
1
投票

要成功运行迁移,您应该首先生成它。为此,运行doctrine:migrations:diff然后运行doctrine:migrations:migrate

© www.soinside.com 2019 - 2024. All rights reserved.