Ticket #377 (closed defect: fixed)

Opened 1 year ago

Last modified 11 months ago

rake dm:db:automigrate not working correctly...

Reported by: chris.kilm..@biego.com Assigned to:
Priority: medium Milestone: The Future
Component: Plugin: DataMapper Keywords: datamapper rake tasks
Cc:

Description

When you run dm:db:automigrate, the following is called:

<code> DataMapper::Base.auto_migrate! </code>

When you run the rake task, the following is the result:

<code> DataObject::QueryError?: Your query failed. Incorrect table name 'data_mapper/bases' CREATE TABLE data_mapper/bases (id int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT) </code>

If you open an irb session, you will see that Base.subclasses is nil.

I opened up the code for DataMapper? 0.2.5 and looked at:

<code> self.prepare_for_persistence </code>

in the *persistence.rb* module.

In *self.prepare_for_persistence, You'll notice that subclasses get added to to the *Persistence* class and not *Base*:

<code> DataMapper::Persistence::subclasses << klass unless klass == DataMapper::Base </code>

Not exactly sure if subclasses should be added to persistence or to base, but if you change <code>dm:db:auto_migrate</code> to the following, the task works:

<code> namespace :dm do

namespace :db do

desc "Perform automigration" task :automigrate => :merb_env do

DataMapper::Persistence.auto_migrate!

end

end

end </code>

Attachments

databases.patch (0.5 kB) - added by flatt..@gmail.com on 01/02/08 14:20:14.

Change History

01/02/08 14:20:14 changed by flatt..@gmail.com

  • attachment databases.patch added.

01/02/08 14:21:57 changed by flatt..@gmail.com

  • keywords set to datamapper rake tasks.
  • owner changed.
  • component changed from Merb to Plugin: DataMapper.

Ooops. Did not see this one.

#387 closed (duplicate)

Patch attached.

Description cleaned up.

01/02/08 14:25:23 changed by flatt..@gmail.com

To format your text, see WikiFormatting. Just noticed that I can't change the description. ;-)

01/07/08 22:38:01 changed by sethrasmuss..@gmail.com

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in r1187