Php 拉威尔+;PostgrelTree
如何编写迁移文件以添加字段类型“ltree”(PostgreSQL) 不起作用Php 拉威尔+;PostgrelTree,php,postgresql,laravel,laravel-5.1,ltree,Php,Postgresql,Laravel,Laravel 5.1,Ltree,如何编写迁移文件以添加字段类型“ltree”(PostgreSQL) 不起作用 谢谢 查看可用功能手册: Laravel的目标是兼容性,所以除非在所有受支持的数据库中都有相同的结构,否则它们不太可能在本地支持它 您可以使用DB::statement('createtable…')手动运行SQL语句。 请记住,您的应用程序将被锁定到postgres,这可能并不理想。请参阅可用功能手册: Laravel的目标是兼容性,所以除非在所有受支持的数据库中都有相同的结构,否则它们不太可能在本地支持它 您
谢谢 查看可用功能手册: Laravel的目标是兼容性,所以除非在所有受支持的数据库中都有相同的结构,否则它们不太可能在本地支持它 您可以使用
DB::statement('createtable…')手动运行SQL语句。
请记住,您的应用程序将被锁定到postgres,这可能并不理想。请参阅可用功能手册: Laravel的目标是兼容性,所以除非在所有受支持的数据库中都有相同的结构,否则它们不太可能在本地支持它 您可以使用
DB::statement('createtable…')手动运行SQL语句。
请记住,您的应用程序将被锁定到postgres,这可能并不理想。作为一种快速解决方案,请在迁移中使用此方法:
public function up ()
{
Schema::create('locations', function (Blueprint $table) {
$table->increments('id');
$table->uuid('uuid')->unique();
$table->string('path', 255); // <--- my ltree field
$table->timestamps();
});
$query = 'ALTER TABLE locations ALTER COLUMN path TYPE "ltree" USING "path"::"ltree";';
\Illuminate\Support\Facades\DB::connection()->getPdo()->exec($query);
}
公共功能启动()
{
Schema::create('locations',函数(Blueprint$表){
$table->increments('id');
$table->uuid('uuid')->unique();
$table->string('path',255);//时间戳();
});
$query='ALTER TABLE locations ALTER列路径类型“ltree”使用“path”:“ltree”;
\照亮\Support\Facades\DB::connection()->getPdo()->exec($query);
}
作为一种快速解决方案在迁移中使用此方法:
public function up ()
{
Schema::create('locations', function (Blueprint $table) {
$table->increments('id');
$table->uuid('uuid')->unique();
$table->string('path', 255); // <--- my ltree field
$table->timestamps();
});
$query = 'ALTER TABLE locations ALTER COLUMN path TYPE "ltree" USING "path"::"ltree";';
\Illuminate\Support\Facades\DB::connection()->getPdo()->exec($query);
}
公共功能启动()
{
Schema::create('locations',函数(Blueprint$表){
$table->increments('id');
$table->uuid('uuid')->unique();
$table->string('path',255);//时间戳();
});
$query='ALTER TABLE locations ALTER列路径类型“ltree”使用“path”:“ltree”;
\照亮\Support\Facades\DB::connection()->getPdo()->exec($query);
}