php 如何正确使用postressql的原则迁移

y3bcpkx1  于 2023-06-21  发布在  PHP
关注(0)|答案(2)|浏览(78)

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

doctrine:schema:update

doctrine:migrations:migrate

返回如下错误:
执行“SELECT min_value,increment_by FROM“abstract_group_id_seq”时发生异常:
SQLSTATE[42703]:未定义列:7错误:列“min_value”不存在
第1行:SELECT min_value,increment_by FROM“abstract_group_id_seq”
这是一个架构名称问题吗?有谁知道如何正确设置教义?谢谢你。

mf98qq94

mf98qq941#

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

s71maibg

s71maibg2#

更改位于文件/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSQL SchemaManager.php中的方法_getPortableSequenceDefinition()
这一个:

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']);
    }

相关问题