
"change_column" doesn't work on MySQL
Reported by hiroyuki | June 1st, 2010 @ 06:20 AM
When I used dm-migration to change column type on MySQL, I got
SQL error and could not migrate. It seems that a SQL statement for
alter column in TableModifier cause error on MySQL.
http://github.com/datamapper/dm-migrations/blob/master/lib/dm-migra...
Following code reproduce problem.
require "dm-core"
require "dm-migrations/migration_runner"
DataMapper.setup(:default, "mysql://dmtest:test@127.0.0.1/dm_test")
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.logger.debug( "Starting Migration" )
migration 1, :create_people_table do
up do
create_table :people do
column :id, Integer, :serial => true
column :name, String, :size => 50
column :age, Integer
end
end
down do
drop_table :people
end
end
migration 2, :modify_people_column do
up do
modify_table :people do
change_column :name, String, :size => 100
end
end
down do
modify_table :people do
change_column :name, String, :size => 50
end
end
end
migrate_up!
When I run the code, I got these outputs:
== Performing Up Migration [#2](/projects/20609/tickets/2 "Ticket #2"): modify_people_column
ALTER TABLE `people` ALTER COLUMN `name` TYPE String
~ 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 'TYPE String' at line 1 (code: 1064, sql state: 42000, query: ALTER TABLE `people` ALTER COLUMN `name` TYPE String, uri: mysql://dmtest:test@127.0.0.1/dm_test)
/Library/Ruby/Gems/1.8/gems/dm-core-0.10.2/lib/dm-core/adapters/data_objects_adapter.rb:61:in `execute_non_query': 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 'TYPE String' at line 1 (DataObjects::SQLError)
Comments and changes to this ticket
-
hiroyuki June 1st, 2010 @ 06:26 AM
I found a duplicated ticket #680 now. please change status of this ticket to "unconfirmed".
thanks.
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »