How to correctly use doctrine migrations with postressql

Viewed 3958

i've got a symfony 2,8 project with a postgressql database and the ID generation strategy is IDENTITY but every command i enter like

doctrine:schema:update

or

doctrine:migrations:migrate

return an error like this:

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

SQLSTATE[42703]: Undefined column: 7 ERROR: column "min_value" does not exist
LINE 1: SELECT min_value, increment_by FROM "abstract_group_id_seq"

Is it a schema name problem? does anybody know how to setup doctrine properly? Thank you
^

2 Answers

If someone else still has this problem, make sure you are using the correct Postgres driver version in doctrine.yaml

PostgreSQL DBAL

Change method _getPortableSequenceDefinition() located in file /vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php

to this one:

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