ERROR relation "access_id_access_seq" does not exist


I update phalcon version from 1.3.4 to 2.0.2 and a get this error

SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "access_id_access_seq" does not exist

#0 [internal function]: PDO->lastInsertId('access_id_acces...')
#1 [internal function]: Phalcon\Db\Adapter\Pdo->lastInsertId('access_id_acces...')
#2 [internal function]: Phalcon\Mvc\Model->_doLowInsert(Object(Phalcon\Mvc\Model\MetaData\Memory), Object(Phalcon\Db\Adapter\Pdo\Postgresql), Array, 'id_access')
#3 /home/ubuntu/workspace/aaaaa/app/library/local/Plugins/RegisterAccess.php(133): Phalcon\Mvc\Model->save()
#4 /home/ubuntu/workspace/aaaaa/app/library/local/Plugins/RegisterAccess.php(45): App\Library\Local\Plugins\RegisterAccess->register()
#5 [internal function]: App\Library\Local\Plugins\RegisterAccess->beforeDispatch(Object(Phalcon\Events\Event), Object(Phalcon\Mvc\Dispatcher), NULL)
#6 [internal function]: Phalcon\Events\Manager->fireQueue(Array, Object(Phalcon\Events\Event))
#7 [internal function]: Phalcon\Events\Manager->fire('dispatch:before...', Object(Phalcon\Mvc\Dispatcher))
#8 [internal function]: Phalcon\Dispatcher->dispatch()
#9 /home/ubuntu/workspace/aaaaa/app/library/local/Bootstrap.php(119): Phalcon\Mvc\Application->handle()
#10 /home/ubuntu/workspace/aaaaa/public/index.php(91): App\Library\Local\Bootstrap->run()
#11 {main}

It is the same program, same database, and worked perfect before the update.

what can be?


Your best bet would be to start logging your MySQL queries.

You could either do it in Phalcon ( ), or using your MySQL general log file (provided it's enabled)

hi, thanks for answer

but, the system its the same, just updated the phalcon version.

the same query is executed. In low-level log, the queries are correct, and in the postgres log I got the same error with phalcon

I think the framework is trying to get a table instead of a sequence, or getting the name of the sequence incorrectly

sorry for my english

Try setting the name of the sequence in the model:

class Robots extends Model
    public function getSequenceName()
        return "my_sequence_name";

yes, this way works, but with the schema name together

but I will have to create a method for each class?

apparently giving this error because they do not take the schema name.

sorry for my english

I've submitted a bug fix in the 2.0.x branch

I got a temporary solution

I have a ModelBase class where we extend the other model classes

and I create this method


use Phalcon\Mvc\Model as PhModel;

class ModelBase extends PhModel

    public function getSequenceName()
        return $this->getSchema() . '.' . $this->getSource() . '_' . $this->modelsMetadata->getIdentityField($this) . '_seq';


class Robots extends ModelBase
// ...