ActiverecordColumnComment

このgemでRails3.2以降のmigrationにおいて、カラムのオプションから comment を指定できます。
普通カラムコメントは必要ないのですが(migrationファイルにrubyコメントで残せるし)、mroongaを使う場合、パーサーの指定がコメント経由なのでこのgemを作りました。

mysqlでしか実際に動かしてみていません。migrationを使うテストの書き方が分からず書いていません。
fork, pull request歓迎です。

This gem will let you add comments on column through options in your migration (rails >= 3.2.0).
Although comments on column are usually not necessary (you can always leave comments in your migration files, right?), I created this gem because I had to use mroonga and specify parser on column.

I only ran and saw results on mysql. Since I didn't know how to write tests using migration, there are no specs/test.
forks, pull requests are very welcomed.

Installation

Add this line to your application's Gemfile:

gem 'activerecord_column_comment'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activerecord_column_comment

Usage

class CreateExamples < ActiveRecord::Migration
  def change
    create_table :examples do |t|
      t.string :name, comment: "put your comment here"
      t.timestamps
    end
  end
end

run rake db:migrate, open mysql console rails dbconsole, then do show create table examples; and you will get this

CREATE TABLE `examples` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'put your comment here',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 

see more in examples folder

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request