Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Store DataMapper::MigrationRunner#migrations in a class variable
Browse files Browse the repository at this point in the history
Fixes an issue where migrations don't get run at
all in dm-rails rake tasks.

Further explanation can be found in the related
ticket on LH. This is weird. Maybe it has to do
something with the way rails loads the rake tasks
and invokes our stuff. No idea ...

[#1214 state:resolved]
  • Loading branch information
snusnu committed Oct 24, 2010
1 parent 5432500 commit cd9d62e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dm-migrations/migration_runner.rb
Expand Up @@ -76,7 +76,7 @@ def migrate_down!(level = nil)
end

def migrations
@migrations ||= []
@@migrations ||= []
end

end
Expand Down

6 comments on commit cd9d62e

@xaviershay
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should put this into a gem release and bump the dependency on dm-rails, this is still broken in rails 3 unless you explicitly point your Gemfile at this repo.

@xaviershay
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'll do it if no one thinks it is a bad idea)

@d11wtq
Copy link

@d11wtq d11wtq commented on cd9d62e Jun 17, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this ever released? rake db:migrate does nothing in Rails 3.0.9.

@d11wtq
Copy link

@d11wtq d11wtq commented on cd9d62e Jun 17, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, in fact, even with dm-migrations pointed to this repo, it does nothing. I must be doing it wrong. It's the first migration I've tried writing with it.

@d11wtq
Copy link

@d11wtq d11wtq commented on cd9d62e Jun 17, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fault. db/migrations/*.rb != db/migrate/*.rb

Carry on...

@kagminjeong
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticket link for those unfortunate to have found this issue the hard way: http://datamapper.lighthouseapp.com/projects/20609/tickets/1214

This fix should have been released in a bug fix 1.0 release.

To work around the failure, you have to define migrations and invoke migrate_up! (or whatever) on the same object. Datamapper includes DataMapper::MigrationRunner into the global namespace, thus if you call migrate globally you have to call migrate_up! globally as well (assuming this works, not tested).

I changed migration definition to read:

DataMapper.migration '2011-10-14T20:09:23Z', :change_commit_message_to_text do

and then invoke it like this:

DataMapper.migrate_up!

Please sign in to comment.