#1323 hold

Issues with dm-migrations (and dm-rails)

Reported by DAddYE | June 16th, 2010 @ 05:07 AM

As reported directly to Dan directly some users point us to an issue with dm-migrations:

In previous version of DM 1.0. for get migrations working with Text , Boolean etc... types we need to use some like this:

create_table :posts do
  column :id, 'INTEGER', :serial => true
  column :title, 'STRING'
  column :description, 'TEXT'
  column :draft, 'BOOLEAN'

But now seem this hack have some problems almost with mysql adapter:

CREATE TABLE `posts` (`id` SERIAL PRIMARY KEY, `title` STRING, `description` TEXT, `draft` BOOLEAN) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
rake aborted!
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STRING, `description` TEXT, `draft` BOOLEAN) ENGINE = InnoDB CHARACTER SET utf8 ' at line 1

So we reverted migrations to:

create_table :posts do
  column :id, Integer, :serial => true
  column :title, String
  column :description, Text
  column :draft, Boolean

But we get:

Performing Up Migration #1: create_posts
rake aborted!
uninitialized constant Text

So now I can't find a way for run correctly migrations.

Then I tried to inspect if we have same problem on dm-rails but on my env Im unable to create/drop databases. I think is a problem of here: http://github.com/datamapper/dm-rails/blob/master/lib/dm-rails/storage.rb#L120

I tried to replace this:


into this:


And worked.

I also need to change this:

@database ||= config['database'] || config['path']

Into this:

@database ||= config['database'] || config['path'].sub(/\//,'')

Consider that now I dropped my rvm rails machine so Im not be able to reproduce all of them.

I made some fixes for our padrino-tasks here: http://github.com/padrino/padrino-framework/blob/master/padrino-gen...

Comments and changes to this ticket

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) June 16th, 2010 @ 01:19 PM

    • Tag set to dm-rails dm-migrations mysql
    • State changed from “new” to “hold”
    • Assigned user changed from “Dan Kubb (dkubb)” to “Martin Gamsjaeger (snusnu)”

    I was talking to Davide on IRC

    He confirmed that doing DataMapper::Property::Text instead of just Text solves the uninitialized constant Text error.

    I (and I know some others who) couldn't reproduce the issue with create/drop complaining about the backticks. I'm not sure, but aren't they explicitly added for portability? Also, Davide couldn't reproduce the issue anymore when trying today afternoon.

    I'm not entirely sure about the last problem concerning .sub(/\//,'') but I've tried all the db related tasks on mysql and didn't notice any problems neither on ruby-1.8.7 nor ruby-1.9.2-preview3.

    I'm not sure what new state is best for this ticket, Davide was saying that it'd be ok for him to close it. I'm assigning it to me and marking it "Hold" for now. Feel free to change.

  • Postmodern

    Postmodern June 25th, 2010 @ 02:12 AM

    This also effects Property classes that are shadowed by Ruby constants, such as DataMapper::Property::URI. I tried using a const_missing hook to access constants from DataMapper::Property but URI is global.

  • Postmodern

    Postmodern June 25th, 2010 @ 02:22 AM

    Injecting "URI = DataMapper::Property::URI" into DataMapper::Migration seems to do the trick. Of course this is in combination with a const_missing hook.

  • Dennison Williams

    Dennison Williams June 26th, 2010 @ 02:03 AM

    • Milestone order changed from “0” to “0”

    I have confirmed that the http://github.com/postmodern/dm-migrations branch has fixed this issue for Text, Boolean, and other types in dm-core. When using URI from dm-types specifying it explicitly as DataMapper::Property::URI ie column :source, DataMapper::Property::URI is a work around for the URI issue.

  • Postmodern

    Postmodern June 28th, 2010 @ 10:33 PM

    My const_missing hook has re-appeared in my fork of dm-core:


  • Piotr Solnica (solnic)

    Piotr Solnica (solnic) May 17th, 2011 @ 02:27 AM

    • Tag changed from dm-rails dm-migrations mysql to dm-migrations

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »