Laravel + PostgreSQL Ltree(Laravel + PostgreSQL Ltree)

编程入门 行业动态 更新时间:2024-10-28 08:31:21
Laravel + PostgreSQL Ltree(Laravel + PostgreSQL Ltree)

如何编写迁移文件以添加字段类型'ltree'(PostgreSQL)

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

不起作用。

谢谢!

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!

最满意答案

查看可用功能的手册: https : //laravel.com/docs/5.1/migrations#creating-columns

Laravel的目标是兼容性,因此除非在所有受支持的数据库中都有相同的结构,否则它们本身不太可能支持它。

您可以使用DB::statement('CREATE TABLE ...') statement手动运行SQL语句DB::statement('CREATE TABLE ...')

请记住,您的应用程序将被锁定到postgres,这可能并不理想。

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.

更多推荐

本文发布于:2023-08-03 11:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1386723.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Laravel   PostgreSQL   Ltree

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!