我对Doctrine Migrations相当陌生,所以很抱歉,如果这真的很明显。主义迁移:改变列在生产中可为空
更新,以提供更多的信息
我有如下一个Symfony2的实体映射:
/**
* @ORM\Column(type="string")
*/
private $name;
将其加入到迁移和一切工作,因为它应该部署。列则需要进行更新,以接受空值,所以又改为:
/**
* @ORM\Column(type="string", nullable=true)
*/
private $name;
的问题是,这对产生迁移文件没有影响:
$ php app/console cache:clear
$ php app/console doctrine:migrations:diff
$ tail -50 app/DoctrineMigrations/Version20131028205742.php
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20131028205742 extends AbstractMigration
{
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
}
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
}
}
没有ALTER语句已经添加以处理空值。我可以删除并重建数据库,但由于此特定迁移已部署,因此会导致生产数据库出现问题。我可以在将来再次看到这种情况,所以想多了解一点。
这是Doctrine和/或Symfony2 Doctrine Migrations捆绑的限制吗?有没有办法解决这个问题,而无需编写自定义迁移?
请注意,我所有的其他迁移工作正常,唯一的问题是添加可空选项到现有的字段。
您是否在生成差异前清除了缓存**?我认为这应该始终是问题出现时的第一个问题:D – nifr
是的,我清除了缓存。我不会认为这是我的问题的路线,虽然其他实体更新通过罚款,而不是ALTER声明为空。 –
你是什么意思由'产生的差异文件'? –