ActiveRecord::Mysql::Comment
Adds column comment and index comment to migrations for ActiveRecord MySQL adapters
Installation
Add this line to your application's Gemfile:
gem 'activerecord-mysql-comment'
And then execute:
$ bundle
Or install it yourself as:
$ gem install activerecord-mysql-comment
Usage
bundle exec rails g migration CreatePosts
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts, options: 'ENGINE=Mroonga COMMENT="default_tokenizer=TokenMecab"' do |t|
t.string :title
t.text :content, comment: 'flags "COLUMN_SCALAR|COMPRESS_ZLIB"'
t.timestamps
end
add_index :posts, :content, type: 'fulltext', comment: 'parser "TokenBigram", normalizer "NormalizerAuto"'
end
end
bundle exec rake db:migrate
create_table "posts", force: :cascade, options: "ENGINE=Mroonga DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='default_tokenizer=TokenMecab'" do |t|
t.string "title", limit: 255
t.text "content", limit: 65535, comment: "flags \"COLUMN_SCALAR|COMPRESS_ZLIB\""
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "posts", ["content"], name: "index_posts_on_content", type: :fulltext, comment: "parser \"TokenBigram\", normalizer \"NormalizerAuto\""
Note
-
Table options need activerecord-mysql-awesome. If you use
rake db:reset
, you should install it. -
If you use activerecord-mysql-awesome, please loading it before load activerecord-mysql-comment.
Contributing
- Fork it ( https://github.com/naoa/activerecord-mysql-comment/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Thanks
This library is made by referring to activerecord-mysql-awesome.