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

Issues with dm-migrations (and dm-rails) #20

Open
solnic opened this issue May 17, 2011 · 6 comments
Open

Issues with dm-migrations (and dm-rails) #20

solnic opened this issue May 17, 2011 · 6 comments
Milestone

Comments

@solnic
Copy link
Contributor

solnic commented May 17, 2011

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'
end

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
end

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:

"CREATE DATABASE `#{database}` DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}"

into this:

"CREATE DATABASE #{database} DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}"

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/lib/padrino-gen/padrino-tasks/datamapper.rb


Created by DAddYE - 2010-06-16 10:07:50 UTC

Original Lighthouse ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/1323

@solnic
Copy link
Contributor Author

solnic commented May 17, 2011

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.

by Martin Gamsjaeger (snusnu)

@solnic
Copy link
Contributor Author

solnic commented May 17, 2011

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.

by Postmodern

@solnic
Copy link
Contributor Author

solnic commented May 17, 2011

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

by Postmodern

@solnic
Copy link
Contributor Author

solnic commented May 17, 2011

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.

by Dennison Williams

@solnic
Copy link
Contributor Author

solnic commented May 17, 2011

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

http://github.com/postmodern/dm-core/commits/postmodern

by Postmodern

@xaviershay
Copy link

Is there a further action on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants