Skip to content
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

[PGsql] Column::TYPE_DOUBLE - Unrecognized PostgreSQL data type at column weight. #111

Closed
yassinrais opened this issue Apr 23, 2021 · 1 comment · Fixed by #116
Closed
Assignees
Labels
bug Something isn't working PostgreSQL
Milestone

Comments

@yassinrais
Copy link

ERROR: Failed to create table 'company_product'. In 'CompanyProductMigration_100' migration. DB error: Unrecognized PostgreSQL data type at column weight

<?php

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

/**
 * Class CompanyProductMigration_100
 */
class CompanyProductMigration_100 extends Migration
{
    /**
     * Define the table structure
     *
     * @return void
     */
    public function morph()
    {
        $this->morphTable('company_product', [
                'columns' => [
                    new Column(
                        'id',
                        [
                            'type' => Column::TYPE_CHAR,
                            'default' => "uuid_generate_v4()",
                            'notNull' => true,
                            'size' => 36,
                            'comment' => "Product ID",
                            'first' => true
                        ]
                    ),
                    new Column(
                        'company_id',
                        [
                            'type' => Column::TYPE_CHAR,
                            'notNull' => true,
                            'size' => 36,
                            'comment' => "Company Id",
                            'after' => 'id'
                        ]
                    ),
                    new Column(
                        'slug',
                        [
                            'type' => Column::TYPE_VARCHAR,
                            'notNull' => true,
                            'size' => 200,
                            'comment' => "Product Slug",
                            'after' => 'company_id'
                        ]
                    ),
                    new Column(
                        'title',
                        [
                            'type' => Column::TYPE_VARCHAR,
                            'notNull' => true,
                            'size' => 200,
                            'comment' => "Product Title",
                            'after' => 'slug'
                        ]
                    ),
                    new Column(
                        'description',
                        [
                            'type' => Column::TYPE_VARCHAR,
                            'notNull' => false,
                            'size' => 400,
                            'comment' => "Product Description",
                            'after' => 'title'
                        ]
                    ),
                    new Column(
                        'sizes',
                        [
                            'type' => Column::TYPE_JSONB,
                            'default' => "[0, 0, 0]",
                            'notNull' => true,
                            'size' => 1,
                            'comment' => "Product Sizes Allowed",
                            'after' => 'description'
                        ]
                    ),
                    new Column(
                        'weight',
                        [
                            'type' => Column::TYPE_DOUBLE,
                            'default' => 0,
                            'notNull' => false,
                            'comment' => "Product Weight",
                            'after' => 'sizes'
                        ]
                    ),
                    new Column(
                        'fragile',
                        [
                            'type' => Column::TYPE_BOOLEAN,
                            'default' => "true",
                            'notNull' => true,
                            'size' => 1,
                            'comment' => "Product Fragile",
                            'after' => 'weight'
                        ]
                    ),
                    new Column(
                        'price',
                        [
                            'type' => Column::TYPE_INTEGER,
                            'default' => "0",
                            'notNull' => true,
                            'size' => 1,
                            'comment' => "Pricing",
                            'after' => 'fragile'
                        ]
                    ),
                    new Column(
                        'created_at',
                        [
                            'type' => Column::TYPE_TIMESTAMP,
                            'default' => "CURRENT_TIMESTAMP",
                            'notNull' => false,
                            'comment' => "Created Date",
                            'after' => 'price'
                        ]
                    ),
                    new Column(
                        'updated_at',
                        [
                            'type' => Column::TYPE_TIMESTAMP,
                            'default' => "CURRENT_TIMESTAMP",
                            'notNull' => false,
                            'comment' => "Update Date",
                            'after' => 'created_at'
                        ]
                    ),
                    new Column(
                        'created_ip',
                        [
                            'type' => Column::TYPE_VARCHAR,
                            'notNull' => false,
                            'size' => 40,
                            'comment' => "Created Ip",
                            'after' => 'updated_at'
                        ]
                    ),
                    new Column(
                        'updated_ip',
                        [
                            'type' => Column::TYPE_VARCHAR,
                            'notNull' => false,
                            'size' => 40,
                            'comment' => "Updated Ip",
                            'after' => 'created_ip'
                        ]
                    )
                ],
                'indexes' => [
                    new Index('pk_product_id', ['id'], '')
                ],
                // 'references' => [
                //     new Reference(
                //         'fk_product_company',
                //         [
                //             'referencedSchema' => 'deliveryapp',
                //             'referencedTable' => 'company',
                //             'columns' => ['company_id'],
                //             'referencedColumns' => ['id'],
                //             'onUpdate' => 'NO ACTION',
                //             'onDelete' => 'NO ACTION'
                //         ]
                //     )
                // ],
            ]
        );
    }

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

    }

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

    }

}
@BeMySlaveDarlin
Copy link
Contributor

Due to type mismatch, replaced TYPE_DOUBLE to TYPE_FLOAT.

@Jeckerson Jeckerson added the bug Something isn't working label May 22, 2021
@Jeckerson Jeckerson added this to the 2.1.x milestone May 22, 2021
@Jeckerson Jeckerson linked a pull request May 22, 2021 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PostgreSQL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants