Closed yassinrais closed 3 years ago
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() { } }
Due to type mismatch, replaced TYPE_DOUBLE to TYPE_FLOAT.
ERROR: Failed to create table 'company_product'. In 'CompanyProductMigration_100' migration. DB error: Unrecognized PostgreSQL data type at column weight