Php 使用laravel创建带有点列的postgres表,无需postGIS扩展

Php 使用laravel创建带有点列的postgres表,无需postGIS扩展,php,laravel,postgresql,Php,Laravel,Postgresql,我对拉拉维尔和博士后是新手。我使用的是没有postGIS扩展的postGres,即使没有postGIS,postGres本身也允许列的点类型,我在幼体中的迁移失败,并导致此错误 Illumb\Database\QueryException:SQLSTATE[42704]:未定义 对象:7错误:字符134处不存在类型“地理” (SQL:创建表“profiles”(“id”bigserial主键不为空, “produc t”varchar(50)不为空,“details”varchar(1000)不

我对拉拉维尔和博士后是新手。我使用的是没有postGIS扩展的postGres,即使没有postGIS,postGres本身也允许列的点类型,我在幼体中的迁移失败,并导致此错误

Illumb\Database\QueryException:SQLSTATE[42704]:未定义 对象:7错误:字符134处不存在类型“地理” (SQL:创建表“profiles”(“id”bigserial主键不为空, “produc t”varchar(50)不为空,“details”varchar(1000)不为空, “xy”地理位置(点4326)不为空,“创建时间”时间戳(0) 如果没有时区null,“更新的时间”时间戳(0)没有时区 空)

下面是我的迁移函数代码

   public function up()
    {
        Schema::connection('pgsql')->create('profiles', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('product',50);
            $table->string('details',1000);
            $table->point('xy');
            $table->timestamps();
        });
    }
xy列是postgres中可用的简单点类型,但laravel似乎将其转换为postGIS中可用的地理类型,我不需要postGIS

请告知如何在没有postGIS的情况下在laravel中创建点列

谢谢


拉维迁移将是

在模式之后的迁移中使用
DB::statement
,例如:
DB::statement('altertable profiles MODIFY xy POINT')如何更改不存在的表?由于上述错误,未创建表。我也是postgress新手(因此可能没有任何帮助),但如果您手动创建表(通过DataGrip或HeidiSql等工具),您是否可以查看
create table
方案以查看创建代码并验证它应该是什么?我想这会让寻找解决方案变得更容易。
I was having same issue with Laravel Migration to create data type point for this  you can use Extended version of PostgresGrammar with support of 'point' data type in Postgres
    <?php
            namespace App\PosGress;
    
            use Illuminate\Database\Schema\Grammars\PostgresGrammar;
            use Illuminate\Support\Fluent;
    
            /**
            * Extended version of PostgresGrammar with
            * support of 'point' data type in Postgres.
            */
            class ExtendedPostgresGrammar extends PostgresGrammar
            {
    
                /**
                * Create the column definition for a spatial Point type.
                *
                * @param  \Illuminate\Support\Fluent  $column
                * @return string
                */
                protected function typePoint(Fluent $column)
                {
                return "$column->type";
                }
    
        }
    ?>
    Laravel Migration will be 
    <?php
    
    use Illuminate\Database\Migrations\Migration;
    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Support\Facades\Schema;
    use App\PosGress\ExtendedPostgresGrammar;
    
    class UpdateTableAddressesAddColumnPoints extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            // register new grammar class
            DB::connection()->setSchemaGrammar(new ExtendedPostgresGrammar());
            $schema = DB::connection()->getSchemaBuilder();
            $schema->table('addresses', function (Blueprint $table) {
                $table->point('geo_location')->nullable(); 
               
             });
        }
    
        /**
         * Reverse the migrations.
         *
         * @return void
         */`enter code here`
        public function down()
        {
            Schema::table('addresses', function (Blueprint $table) {
                $table->dropColumn('geo_location');
            });
        }
    }