Access denied, Please sign in and make sure you have proper permission.

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

ratazzi · September 17, 2025 · 11 hits

因为原帖关闭了回复,所以单独发一个,我喜欢用 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"
No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.