Symfony和教义使迁移无效 [英] Symfony and Doctrine making migration with no effect

查看:146
本文介绍了Symfony和教义使迁移无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Doctrine正在symfony中生成迁移,并且在运行迁移后没有任何变化,因此在下一个diff期间是相同的.如何使教义不产生这种迁移?手动运行alter table命令不会删除列排序规则.

Doctrine is generating migration in symfony and nothing changes afer running the migration so during next diff it is the same. How to make Doctrine not generate this migration? Running the alter table command manually does not remove column collation.

bin/console doctrine:migration:diff

$this->addSql('ALTER TABLE session CHANGE sess_id sess_id VARCHAR(128) NOT NULL');

$this->addSql('ALTER TABLE session CHANGE sess_id sess_id VARCHAR(128) NOT NULL COLLATE utf8_unicode_ci');

表如下所示:

show create table session;    

创建表session( sess_id varchar(128)收集utf8_unicode_ci NOT NULL, sess_data longblob NOT NULL, sess_time int(11)非空, sess_lifetime int(11)非空, 主键(sess_id) )ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci

CREATE TABLE session ( sess_id varchar(128) COLLATE utf8_unicode_ci NOT NULL, sess_data longblob NOT NULL, sess_time int(11) NOT NULL, sess_lifetime int(11) NOT NULL, PRIMARY KEY (sess_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

实体是在添加如下所示的排序规则之后

Entity is after adding collation like below

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Session
 *
 * @ORM\Table(name="session")
 * @ORM\Entity(repositoryClass="App\Repository\SessionRepository")
 */
class Session
{
    /**
     * @var string
     *
     * @ORM\Column(name="sess_id", type="string", length=128, options={"collation":"utf8_unicode_ci"})
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="sess_data", type="blob")
     */
    private $sessData;

    /**
     * @var int
     *
     * @ORM\Column(name="sess_time", type="integer")
     */
    private $sessTime;

    /**
     * @var int
     *
     * @ORM\Column(name="sess_lifetime", type="integer")
     */
    private $sessLifetime;


    /**
     * Get id
     *
     * @return string
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Get sessData
     *
     * @return string
     */
    public function getSessData()
    {
        return $this->sessData;
    }

    /**
     * Set sessData
     *
     * @param string $sessData
     *
     * @return Session
     */
    public function setSessData($sessData)
    {
        $this->sessData = $sessData;

        return $this;
    }

    /**
     * Get sessTime
     *
     * @return int
     */
    public function getSessTime()
    {
        return $this->sessTime;
    }

    /**
     * Set sessTime
     *
     * @param integer $sessTime
     *
     * @return Session
     */
    public function setSessTime($sessTime)
    {
        $this->sessTime = $sessTime;

        return $this;
    }

    /**
     * Get sessLifetime
     *
     * @return int
     */
    public function getSessLifetime()
    {
        return $this->sessLifetime;
    }

    /**
     * Set sessLifetime
     *
     * @param integer $sessLifetime
     *
     * @return Session
     */
    public function setSessLifetime($sessLifetime)
    {
        $this->sessLifetime = $sessLifetime;

        return $this;
    }
}

推荐答案

我遇到了类似的问题.

我使用:

  • Symfony = 3.4.9(flex)
    • 主义/orm=^2.5.11
    • Symfony=3.4.9 (flex)
      • doctrine/orm=^2.5.11


      要解决我的问题,请评论或在config/packages/doctrine.yaml中的属性server_version上设置值'mariadb-10.2.14'.

      For correct my problem, commented OR set value 'mariadb-10.2.14' on the property server_version in config/packages/doctrine.yaml.


      灵感来自于: https://github.com/doctrine/dbal/issues/2985

      这篇关于Symfony和教义使迁移无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆