We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Adapter\Pdo\Postgresql Sequence Name character limit

I came into the problem today where if a postgres table has a long name and a sequenced id, then the sequence name is truncated by postgres. However, the postgres adapter looks for the untruncated name.

For example, given a table: sales_order_fitting_confirmation

Postgres generates a sequence name of: sales_order_fitting_confirmat_id_sales_order_fitting_confir_seq

Postgres adapter searches for sequence name: sales_order_fitting_confirmation_id_sales_order_fitting_confirmation_seq

Throwing the following error on save: PDOException: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "sales_order_fitting_confirmation_id_sales_order_fitting_confirm" does not exist

Is there a way to force a sequence name in a model? Should this behaviour not be also built into the adapter? Thanks for the help guys

edited Apr '16

I tried adding the following to the Model:

     * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData
     * @param \Phalcon\Db\AdapterInterface $connection
     * @param array|string $table
     * @param bool|string $identityField
     * @return bool
    protected function _doLowInsert(
        \Phalcon\Mvc\Model\MetaDataInterface $metaData,
        \Phalcon\Db\AdapterInterface $connection,
        $identityField) {
        $table = substr($table, 0, 29);
        $identityField = substr($identityField, 0, 29);
        return parent::_doLowInsert(

But that just resulted in the following error instead: Phalcon\Mvc\Model\Exception: Identity column 'id_sales_order_fitting_confir' isn't part of the column map

You can try


use Phalcon\Mvc\Model;

class SalesOrderFittingConfirmation extends Model
    public function getSequenceName()
        return "sales_order_fitting_confirmat_id_sales_order_fitting_confir_seq";

More info: https://docs.phalcon.io/en/latest/reference/models.html#auto-generated-identity-columns