Activerecord::SimpleIndexName
Shorten index name
Supported
- Ruby on Rails
- Padrino
- or plain activerecord
Installation
Add this line to your application's Gemfile:
gem 'activerecord-simple_index_name'
And then execute:
$ bundle
Or install it yourself as:
$ gem install activerecord-simple_index_name
Usage
When run rake db:migrate (or rake ar:migrate), index name will be automatically short.
Example
create_table :user_stocks do |t|
t.integer :user_id, null: false
t.integer :article_id, null: false
t. null: false
end
add_index :user_stocks, [:user_id, :article_id]
- Index name without
activerecord-simple_index_name:index_user_stocks_on_user_id_and_article_id - Index name with
activerecord-simple_index_name:user_id_and_article_id
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/sue445/activerecord-simple_index_name.
License
The gem is available as open source under the terms of the MIT License.
Special thanks
@kamipo :bow:
Original idea is http://qiita.com/kamipo/items/6e5a1e238d7cc0611ade (ja)