New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL migration error #1118

Closed
Urvin opened this Issue Oct 5, 2017 · 6 comments

Comments

Projects
None yet
4 participants
@Urvin

Urvin commented Oct 5, 2017

Expected and Actual Behavior

I've created a migration using devtools and now i'm trying to run it on a clean PostgreSQL database.
Both cli- and web- interface give me an exception.

Here's the cli output:

1507010432.9594: CREATE TABLE "printtime"."rbac" ( DEFAULT true"id" SERIAL NOT NULL, "code" CHARACTER VARYING(20) NOT NULL, "description" CHARACTER VARYING(255) NOT NULL, "isrole" BOOLEAN NOT NULL, "children" CHARACTER VARYING(1), CONSTRAINT "rbacpkey" PRIMARY ("id") );ERROR: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "DEFAULT" LINE 2: DEFAULT true"id" SERIAL NOT NULL,

You see, there's a wrong sql command DEFAULT true"id" SERIAL NOT NULL, there's no backspace and presents an unneeded command DEFAULT true.

Here's my morph part of the migration:

$this->morphTable('rbac', [
                'columns' => [
                    new Column(
                        'id',
                        [
                            'type' => Column::TYPE_INTEGER,
                            'notNull' => true,
                            'autoIncrement' => true,
                            'first' => true
                        ]
                    ),
                    new Column(
                        'code',
                        [
                            'type' => Column::TYPE_VARCHAR,
                            'notNull' => true,
                            'size' => 20,
                            'after' => 'id'
                        ]
                    ),
                    new Column(
                        'description',
                        [
                            'type' => Column::TYPE_VARCHAR,
                            'notNull' => true,
                            'size' => 255,
                            'after' => 'code'
                        ]
                    ),
                    new Column(
                        'is_role',
                        [
                            'type' => Column::TYPE_BOOLEAN,
                            'default' => "false",
                            'notNull' => true,
                            'after' => 'description'
                        ]
                    ),
                    new Column(
                        'children',
                        [
                            'type' => Column::TYPE_VARCHAR,
                            'notNull' => false,
                            'size' => 1,
                            'after' => 'is_role'
                        ]
                    )
                ],
                'indexes' => [
                    new Index('rbac_pkey', ['id'], 'PRIMARY')
                ],
            ]
        );

Details

  • OS: Linux y 4.10.0-35-generic #39~16.04.1-Ubuntu SMP Wed Sep 13 09:02:42 UTC 2017 x86_64
  • PHP Version: 7.0.22-0ubuntu0.16.04.1
  • Phalcon DevTools Version: 3.2.3
  • Phalcon Version: 3.2.2
  • PostgreSQL 9.5
@sergeyklay

This comment has been minimized.

Show comment
Hide comment
@sergeyklay

sergeyklay Oct 8, 2017

Member

@Urvin Could you please try latest stable DevTools version?

Member

sergeyklay commented Oct 8, 2017

@Urvin Could you please try latest stable DevTools version?

@Urvin

This comment has been minimized.

Show comment
Hide comment
@Urvin

Urvin Oct 9, 2017

It's OK now.
Thanks!

Urvin commented Oct 9, 2017

It's OK now.
Thanks!

@sergeyklay sergeyklay closed this Oct 9, 2017

@jonkofee

This comment has been minimized.

Show comment
Hide comment
@jonkofee

jonkofee Nov 1, 2017

У меня такая же проблема, стоит последняя версия.

$this->morphTable($this->_tableName, [
                'columns' => [
                    new Column(
                        'id',
                        [
                            'type' => Column::TYPE_INTEGER,
                            'notNull' => true,
                            'autoIncrement' => true,
                            'first' => true
                        ]
                    ),
                    new Column(
                        'user_id',
                        [
                            'type' => Column::TYPE_INTEGER,
	                        'notNull' => true,
                        ]
                    ),
	                new Column(
		                'track_id',
		                [
			                'type' => Column::TYPE_INTEGER,
			                'notNull' => true,
		                ]
	                ),
	                new Column(
		                'like',
		                [
			                'type' => Column::TYPE_BOOLEAN,
			                'notNull' => true,
			                'default' => 0,
		                ]
	                ),
	                new Column(
		                'dislike',
		                [
			                'type' => Column::TYPE_BOOLEAN,
			                'notNull' => true,
			                'default' => 0,
		                ]
	                ),
                ],
                'indexes' => [
                    new Index('rating_pkey', ['id'], 'PRIMARY KEY'),
                    new Index('rating_user_id', ['user_id']),
	            new Index('rating_track_id', ['track_id']),
	            new Index('rating_like', ['like']),
	            new Index('rating_dislike', ['dislike'])
                ],
            ]
        );
CREATE TABLE "public"."rating" (
DEFAULT false DEFAULT false"id" SERIAL NOT NULL, 
"user_id" INT NOT NULL,  "track_id" INT NOT NULL, 
"like" BOOLEAN NOT NULL, 
"dislike" BOOLEAN NOT NULL,
CONSTRAINT "rating_pkey" PRIMARY KEY ("id") );

А должно быть

CREATE TABLE "public"."rating" (
"id" SERIAL NOT NULL, 
"user_id" INT NOT NULL,  "track_id" INT NOT NULL, 
"like" BOOLEAN NOT NULL DEFAULT false, 
"dislike" BOOLEAN NOT NULL DEFAULT false,
CONSTRAINT "rating_pkey" PRIMARY KEY ("id") );

И такое происходить только с boolean

jonkofee commented Nov 1, 2017

У меня такая же проблема, стоит последняя версия.

$this->morphTable($this->_tableName, [
                'columns' => [
                    new Column(
                        'id',
                        [
                            'type' => Column::TYPE_INTEGER,
                            'notNull' => true,
                            'autoIncrement' => true,
                            'first' => true
                        ]
                    ),
                    new Column(
                        'user_id',
                        [
                            'type' => Column::TYPE_INTEGER,
	                        'notNull' => true,
                        ]
                    ),
	                new Column(
		                'track_id',
		                [
			                'type' => Column::TYPE_INTEGER,
			                'notNull' => true,
		                ]
	                ),
	                new Column(
		                'like',
		                [
			                'type' => Column::TYPE_BOOLEAN,
			                'notNull' => true,
			                'default' => 0,
		                ]
	                ),
	                new Column(
		                'dislike',
		                [
			                'type' => Column::TYPE_BOOLEAN,
			                'notNull' => true,
			                'default' => 0,
		                ]
	                ),
                ],
                'indexes' => [
                    new Index('rating_pkey', ['id'], 'PRIMARY KEY'),
                    new Index('rating_user_id', ['user_id']),
	            new Index('rating_track_id', ['track_id']),
	            new Index('rating_like', ['like']),
	            new Index('rating_dislike', ['dislike'])
                ],
            ]
        );
CREATE TABLE "public"."rating" (
DEFAULT false DEFAULT false"id" SERIAL NOT NULL, 
"user_id" INT NOT NULL,  "track_id" INT NOT NULL, 
"like" BOOLEAN NOT NULL, 
"dislike" BOOLEAN NOT NULL,
CONSTRAINT "rating_pkey" PRIMARY KEY ("id") );

А должно быть

CREATE TABLE "public"."rating" (
"id" SERIAL NOT NULL, 
"user_id" INT NOT NULL,  "track_id" INT NOT NULL, 
"like" BOOLEAN NOT NULL DEFAULT false, 
"dislike" BOOLEAN NOT NULL DEFAULT false,
CONSTRAINT "rating_pkey" PRIMARY KEY ("id") );

И такое происходить только с boolean

@sergeysviridenko

This comment has been minimized.

Show comment
Hide comment
@sergeysviridenko

sergeysviridenko Nov 1, 2017

Contributor

@jonkofee could you open new issue with steps to reproduce, please?

Contributor

sergeysviridenko commented Nov 1, 2017

@jonkofee could you open new issue with steps to reproduce, please?

@Urvin

This comment has been minimized.

Show comment
Hide comment
@Urvin

Urvin Nov 1, 2017

It's a cphalcon bug, see phalcon/cphalcon#13132

Urvin commented Nov 1, 2017

It's a cphalcon bug, see phalcon/cphalcon#13132

@sergeysviridenko

This comment has been minimized.

Show comment
Hide comment
@sergeysviridenko

sergeysviridenko Nov 20, 2017

Contributor

@Urvin This problem was solved.

Contributor

sergeysviridenko commented Nov 20, 2017

@Urvin This problem was solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment