phppostgresqllaravellaravel-5.1ltree

Laravel + PostgreSQL Ltree


How to write the migration file to add the field type 'ltree' (PostgreSQL)

Schema::create('table', function (Blueprint $table) {
     ....
$table->ltree('path');
}

Does not work.

Thanks!


Solution

  • Look to the manual of the functions available: https://laravel.com/docs/5.1/migrations#creating-columns

    Laravel's goal is compatibility, so unless there is equivalent structures in all supported databases, they aren't likely to support it natively.

    You can run SQL statements manually using DB::statement('CREATE TABLE ...')

    Just keep in mind that your application will be locked to postgres which may not be ideal.