yii2:迁移表

时间:2016-07-15 20:13:28

标签: yii2

我正在学习Yii2框架。我的MySQL表中有一个geometry type column。我想知道我是否可以使用Yii2迁移表创建它。不幸的是,yii\db\SchemaBuilderTrait类中没有这样的geometry()方法,所以我假设以下方法不起作用:

 $this->createTable('{{%gps}}', [
            ...

            'gps' => $this->geometry()->notNull()       

            ...
 ]);

有没有人知道这方面的任何解决方法?

1 个答案:

答案 0 :(得分:2)

我没有用于创建几何图形,但您也可以使用哈希格式创建列

use yii\db\Schema;
use yii\db\Migration;




    $this->createTable('Your_table ', [ 
        'id' =>  'pk',
        'user_id' =>  'integer not null',             
        'land_scope_code' => 'string(4)',    
        'init_lat' => 'decimal(24,20)',
        'init_lng' => 'decimal(24,20)',
        'init_zoom' => 'integer',

    ]);

可能对你的

有用
$this->createTable('{{%gps}}', [
        ...

        'gps' => 'geometry not null';       

        ...
]);
相关问题