iamssingh
1 month ago
474
20
Laravel

Unable to migrate table using point datatype in postgres ?

Posted 1 month ago by iamssingh

I have a migration file which contains point datatype. It is laravel 5.8. While migrating I am getting below error.

  Illuminate\Database\QueryException  : SQLSTATE[42704]: Undefined object: 7 ERROR:  type "geography" does not exist at character 92 (SQL: create table "clients_users_locations" ("id" bigserial primary key not null, "point_table" geography(geometry, 4326) not null, "created_by" bigint not null, "created_at" timestamp(0) with time zone not null))

  at /opt/lampp/htdocs/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42704]: Undefined object: 7 ERROR:  type "geography" does not exist at character 92")
      /opt/lampp/htdocs/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:129

  2   PDOException::("SQLSTATE[42704]: Undefined object: 7 ERROR:  type "geography" does not exist at character 92")


Here is my migration file -

    public function up()
    {
        Schema::create('clients_users_locations', function (Blueprint $table) {
            $table->bigInteger('id', true);
            $table->geometry('point_table');
            $table->bigInteger('created_by');
            $table->datetimetz('created_at');
        });
    }

What am I missing here ?

Please sign in or create an account to participate in this conversation.