如何使用postressql正确使用doctrine迁移

时间:2017-11-20 17:10:04

标签: php postgresql doctrine symfony-2.8

我有一个带有postgressql数据库的symfony 2,8项目,ID生成策略是IDENTITY,但我输入的每个命令都是

doctrine:schema:update

doctrine:migrations:migrate

返回如下错误:

 An exception occurred while executing 'SELECT min_value, increment_by FROM "abstract_group_id_seq"':  

SQLSTATE [42703]:未定义列:7错误:列“min_value”不存在
  第1行:选择min_value,increment_by FROM“abstract_group_id_seq”

是架构名称问题吗?有人知道如何正确设置学说吗?谢谢你                  ^

2 个答案:

答案 0 :(得分:1)

如果其他人仍有此问题,请确保您在doctrine.yaml中使用正确的Postgres驱动程序版本

PostgreSQL DBAL

答案 1 :(得分:0)

更改方法_getPortableSequenceDefinition()位于文件/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php

到这一个:

 protected function _getPortableSequenceDefinition($sequence)
    {
        if ($sequence['schemaname'] != 'public') {
            $sequenceName = $sequence['schemaname'] . "." . $sequence['relname'];
        } else {
            $sequenceName = $sequence['relname'];
        }

        $version = floatval($this->_conn->getWrappedConnection()->getServerVersion());

        if ($version >= 10) {$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM pg_sequences WHERE schemaname = \'public\' AND sequencename = '.$this->_conn->quote($sequenceName));
        }
        else
        {
            $data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName));
        }

        return new Sequence($sequenceName, $data[0]['increment_by'], $data[0]['min_value']);
    }