问题描述
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;
实体是在添加如下所示的排序规则之后
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
inconfig/packages/doctrine.yaml
.
灵感来自于: https://github.com/doctrine/dbal/issues/2985
这篇关于Symfony和教义使迁移无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!