雄辩的ORM和postgres迁移 - 是否可以分配表达式默认值?

时间:2017-07-15 01:29:00

标签: postgresql laravel orm eloquent

我正在阅读an article on secure storage of credentials with postgres,其中推荐随机uuids与自动增量id

在原始postgresql中它会是这样的:

id uuid NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY

然而,凭借雄辩,我无法弄清楚如何实现这样的目标。 eloquent docs for 5.4提及->storedAs($expression)不幸仅限于MySQL。这对postgres来说根本不可能吗?

1 个答案:

答案 0 :(得分:0)

尝试 - >默认(DB :: raw('gen_random_uuid()'));

它存在于query builder文档