Skip to content

PostgreSQL using sequences issue #853

@morrigan

Description

@morrigan

Hi,
this is the issue I am facing when running migrations on production. Any tips? Using Phalcon DevTools (2.0.13).

Error:

CREATE TABLE "public"."images" (
  "id" BIGSERIAL DEFAULT "nextval('images_id_seq'::regclass)" NOT NULL,
  "base64" TEXT
);
ERROR: SQLSTATE[42601]: Syntax error: 7 ERROR:
multiple default values specified for column "id" of table "images"

Generated migration file:

<?php

use Phalcon\Db\Column;
use Phalcon\Db\Index;
use Phalcon\Db\Reference;
use Phalcon\Mvc\Model\Migration;

/**
 * Class ImagesMigration_101
 */
class ImagesMigration_101 extends Migration
{
    /**
     * Define the table structure
     *
     * @return void
     */
    public function morph()
    {
        $this->morphTable('images', array(
                'columns' => array(
                    new Column(
                        'id',
                        array(
                            'type' => Column::TYPE_BIGINTEGER,
                            'default' => "nextval('images_id_seq'::regclass)",
                            'notNull' => true,
                            'autoIncrement' => true,
                            'first' => true
                        )
                    ),
                    new Column(
                        'base64',
                        array(
                            'type' => Column::TYPE_TEXT,
                            'size' => 1,
                            'after' => 'id'
                        )
                    )
                ),
                'indexes' => array(
                    new Index('pk_image_id', array('id'), null)
                ),
            )
        );
    }

    /**
     * Run the migrations
     *
     * @return void
     */
    public function up()
    {

    }

    /**
     * Reverse the migrations
     *
     * @return void
     */
    public function down()
    {

    }

}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions