Postgresql 创建;“几何学”;使用迁移的数据类型?

Postgresql 创建;“几何学”;使用迁移的数据类型?,postgresql,laravel,Postgresql,Laravel,文本很容易做到: $table->text('description'); 但是你会如何为postgres做一个,最终会给你一个类型为“geometry”的列呢?,内置的列类型列表中没有列类型geometry。因此,在迁移中使用自定义SQL: <?php use Illuminate\Database\Migrations\Migration; class AddGeometryColumnToMyTable extends Migration { public fu

文本很容易做到:

$table->text('description');
但是你会如何为postgres做一个,最终会给你一个类型为“geometry”的列呢?

,内置的列类型列表中没有列类型
geometry
。因此,在迁移中使用自定义SQL:

<?php

use Illuminate\Database\Migrations\Migration;

class AddGeometryColumnToMyTable extends Migration 
{
    public function up()
    {
        DB::statement('ALTER TABLE some_table ADD COLUMN geom geometry(Point,4326);');
    }

    public function down()
    {
        DB::statement('ALTER TABLE some_table DROP COLUMN geom RESTRICT;');
    }
}
,内置的列类型列表中没有列类型
几何图形
。因此,在迁移中使用自定义SQL:

<?php

use Illuminate\Database\Migrations\Migration;

class AddGeometryColumnToMyTable extends Migration 
{
    public function up()
    {
        DB::statement('ALTER TABLE some_table ADD COLUMN geom geometry(Point,4326);');
    }

    public function down()
    {
        DB::statement('ALTER TABLE some_table DROP COLUMN geom RESTRICT;');
    }
}