Skip to content

Instantly share code, notes, and snippets.

@odlp
Created June 26, 2017 08:29
Show Gist options
  • Save odlp/08a42dbfacef5dbfeacb6e699c867c34 to your computer and use it in GitHub Desktop.
Save odlp/08a42dbfacef5dbfeacb6e699c867c34 to your computer and use it in GitHub Desktop.
Case-insensitive unique constraint in Postgres
class UniqueUserEmail < ActiveRecord::Migration[5.1]
def change
enable_extension :citext
change_column :users, :email, :citext
add_index :users, :email, unique: true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment