Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何通过cakephp phinx迁移迁移列类型DOUBLE?_Mysql_Cakephp_Migration_Phinx - Fatal编程技术网

Mysql 如何通过cakephp phinx迁移迁移列类型DOUBLE?

Mysql 如何通过cakephp phinx迁移迁移列类型DOUBLE?,mysql,cakephp,migration,phinx,Mysql,Cakephp,Migration,Phinx,我试图使用迁移将表从db1迁移到db2,但有一个表的列类型为DOUBLE,我遇到了一个问题。我知道有支持的类型,但是可以指定FLOATtype以在差异迁移中获得DOUBLE?我使用cakephp版本3.5.6 我的迁移示例 <?php use Migrations\AbstractMigration; class Diff003 extends AbstractMigration { public function up() { $this->table('

我试图使用迁移将表从db1迁移到db2,但有一个表的列类型为
DOUBLE
,我遇到了一个问题。我知道有支持的类型,但是可以指定
FLOAT
type以在差异迁移中获得
DOUBLE
?我使用cakephp版本3.5.6

我的迁移示例

<?php
   use Migrations\AbstractMigration;

   class Diff003 extends AbstractMigration
{

public function up()
{

    $this->table('test_double')
        ->addColumn('double1', 'float', [ // here type DOUBLE is changing to  FLOAT
            'default' => null,
            'limit' => null,
            'null' => true,
        ])
        ->addColumn('double2', 'float', [
            'default' => null,
            'limit' => null,
            'null' => true,
        ])
        ->create();
}

public function down()
{

    $this->dropTable('test_double');
}

类型最近已经实现,可能会在下一个Phinx版本中提供(从版本0.10.7开始添加),请参见

在此之前,您可以使用以下工具:

或者通过原始SQL手动添加列,例如:

$this->execute('ALTER TABLE test_double ADD COLUMN double1 DOUBLE NULL');
或者,如果您喜欢冒险,请使用Phinx master分支,直到稳定版本可用:

composer require robmorgan/phinx:dev-master

谢谢你的回答:)
composer require robmorgan/phinx:dev-master
->addColumn('double1', 'double', [
    // ...
])