访问被拒绝,你可能没有权限或未登录。

Rails 关于 Postgresql 使用 NULLS NOT DISTINCT 还是无法唯一索引允许多个 NULL

ratazzi · 2025年09月17日 · 11 次阅读

因为原帖关闭了回复,所以单独发一个,我喜欢用 PostgreSQL 的一个原因就是条件索引(Partial Indexes)

add_index :users, :auth_token, unique: true, where: "auth_token IS NOT NULL"
add_index :users, :password_reset_token, unique: true, where: "password_reset_token IS NOT NULL"
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号