pinnymz / migration_comments

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

What if you are using Active Record > 4.2 but Ruby < 2.1 ? Weird conflict with UUIDs #40

Closed maryammouse closed 3 years ago

maryammouse commented 6 years ago

I'm having difficulty replicating this issue, and it may well a problem elsewhere. However, if I use ActiveRecord 4's built-in :uuid functionality (so it can set a primary key as a uuid that generates by itself) , then that functionality breaks whenever this gem is installed.

If I use 0.3.2, then my migrations fail as for some reason no default is set for the primary uuid key column. I do not understand why. My guess is that somehow the way dependencies are set means that an older version of ActiveRecord gets used to run migrations?

If I use 0.4.1, the migrations work fine, but I run into this issue which I suspect is related to the fact that my app uses Ruby 2.0.0:

 bundle exec rake --trace --verbose assets:precompile
 ---> Running in e1302b7e04fc
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'migration_comments'.
Gem Load Error is: private method `prepend' called for ActiveRecord::SchemaDumper:Class
Backtrace for gem load error is:
/gems/gems/migration_comments-0.4.1/lib/migration_comments.rb:27:in `block in setup'
/gems/gems/migration_comments-0.4.1/lib/migration_comments.rb:23:in `each'
/gems/gems/migration_comments-0.4.1/lib/migration_comments.rb:23:in `setup'
/gems/gems/migration_comments-0.4.1/lib/migration_comments.rb:59:in `<top (required)>'
/usr/lib64/ruby/site_ruby/2.0.0/bundler/runtime.rb:81:in `require'
/usr/lib64/ruby/site_ruby/2.0.0/bundler/runtime.rb:81:in `block (2 levels) in require'
/usr/lib64/ruby/site_ruby/2.0.0/bundler/runtime.rb:76:in `each'
/usr/lib64/ruby/site_ruby/2.0.0/bundler/runtime.rb:76:in `block in require'

Would really love to get to the bottom of this!

pinnymz commented 6 years ago

@maryammouse v0.4.1 requires ruby 2.2 or higher precisely because of support for the prepend keyword. The issue you are seeing with v0.3.2 is a duplicate of #14 - which is addressed by PR #15 , but the first released version to get this fix is v0.4.1.

At this point, I believe you have two choices: 1) Fork the repo and apply the commit that fixes this (https://github.com/pinnymz/migration_comments/pull/15/commits/c47d86df8d6d95bae9105ec9e9bdff61a1d1e0f7) to the v0.3.2 release 2) Upgrade to Ruby 2.2 or higher (strongly recommended)