rails/rails — pull request #13684 by jbaudanza (2014-01-12 18:38:42+00:00)
Title: Light support for postgres expression indexes

This PR allows you to generate indexes that are wrapped in a SQL function. For example:

```ruby
add_index :users, :email, unique: true, function: 'lower'
```

will generate:

```sql
CREATE UNIQUE INDEX index_users_on_lower_email_index ON users (LOWER(email))
```

This allows you to index for the common postgres use case:

```ruby
user = User.where('LOWER(email) = LOWER(?)', params[:email]).first
if user && user.authenticate(params[:password])
...
```

The schema dumper will currently only dump functions on single column indexes, but I can extend to support composite indexes if there is interest.

This PR only allows for simple expressions such as `lower(email)`. To use more complex expressions, it's probably better to use the SQL schema dumper.