Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在使用 FluentMigrator 创建表时添加“lower(title)”,我想在 postgre 中使用不区分大小写的唯一约束
据我所知,您无法在表定义中解决此问题,因为UNIQUE约束只会接受列名。您可以使用 UNIQUE 子句在标题列上创建索引,这可以有效地执行您想要的操作:
UNIQUE
CREATE UNIQUE INDEX title_unique ON table_name (lower(title));
当然,这也为您提供了一个明确的标题索引,无论如何都是强制执行约束所必需的。