pinnymz / migration_comments

Comments for your migrations
MIT License
173 stars 31 forks source link

comment parameter for add_column #22

Closed Smarre closed 9 years ago

Smarre commented 9 years ago

Hi,

I have a feature request: I don’t know if this should be supported (documentation doesn’t say so I assume no), but syntax like

add_column :table, :column, :string, comment: "nyaa"

should be supported. At the moment, after adding new column, it would be needed to call set_new_comment after adding the new column, resulting to duplicating some information.

pinnymz commented 9 years ago

This feature is already supported, albeit implicitly. I've added tests to ensure support will remain.

Smarre commented 9 years ago

It didn’t work for me though, I didn’t get a comment in my column, with MySQL...

pinnymz commented 9 years ago

Strange... I just tested it with MySQL and it seemed to work properly. Can you create a test case that demonstrates this?

Smarre commented 9 years ago

Okay, by any chance, did you use trunk version? I assume you did.

Looks like Activerecord 4 support has been committed after it, I’m using stable version of 0.3.2, maybe that is the problem... I’ll test with trunk version.

Smarre commented 9 years ago

Nope, still not working, with current trunk. What kind of test would you like for this? I don’t really know how to do simple test for Activerecord (my environment is based to still unreleased/closed source so I can’t provide the gem I’m using for it, so I need to create different kind of system to run the migration for just the test).

pinnymz commented 9 years ago

Please see https://github.com/pinnymz/migration_comments/blob/master/test/add_comments_test.rb#L29 for an example. It may also be helpful to see a list of gems you are using, as it's possible there's some incompatibility somewhere.

yesnik commented 9 years ago

Hello, I HAD the same issue. But then I found out that I didn't install gem migration_comments in my project correctly. That's why my migration failed with error: undefined methodset_column_comment ...`. After correct installation the following migrations worked for me:

class AddCurrentActivityDatesToCompanies < ActiveRecord::Migration
  def self.up
    add_column :companies, :current_activity_starts_on, :date, comment: 'Comment 1'
    set_column_comment :companies, :current_activity_ends_on, 'Comment 2'
    # ...
  end
  # ...
end

So, this gem works correctly in my environment: Ruby: 1.9.3-p547, Rails: 3.2.22, PostgreSQL: 9.2.13, Bundler: 1.7.9.

pinnymz commented 9 years ago

@yesnik glad to hear that you can confirm this. I'm closing the issue for now.