Hey

I have had a problem with my migration scripts (using 2.12.0 and
2.11.0) and I tracked it down to when I execute alter table commands
using sql then run try to add a foreign key to and existing table. I
get an exception like...

Mysql::Error Can't create table 'test.#sql-90_15d' (errno: 150)

Here is an example script that will reproduce the behavior (it just
assumes you have a mysql database called test)

require "rubygems"
require "sequel"

DB = Sequel.mysql(:host => "localhost", :user => "root", :database =>
"test")

DB.create_table(:users) do
  primary_key :id
  varchar :email, :size => 255, :null => false, :index => true
  varchar :crypted_password, :size => 40, :null => false
  varchar :salt, :size => 40, :null => false
end
DB.execute 'ALTER TABLE users ENGINE = InnoDB'
DB.execute 'ALTER TABLE users DEFAULT CHARACTER SET utf8'

DB.create_table(:cards) do
  primary_key :id
end
DB.execute 'ALTER TABLE cards ENGINE = InnoDB'
DB.execute 'ALTER TABLE cards DEFAULT CHARACTER SET utf8'


DB.alter_table(:cards) do
  add_foreign_key :user_id, :users
end

cheers
Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to