On Tuesday, October 9, 2012 2:17:10 AM UTC+2, Joshua Hansen wrote:
>
> I'm working with an existing MySQL schema and am adapting Sequel to work 
> with it for a Rails project. The primary keys of most of the database are 
> binary blobs representing UUIDs. I used Sequel's schema dumper as a 
> starting place for future migrations and got something like this:
>
>     create_table(:example_table, :ignore_index_errors=>true) do
>       File :id, :size=>16, :null=>false
>
>       primary_key [:id]
>
>       index [:id], :name=>:id_UNIQUE, :unique=>true, :size=>16
>     end
>
> Unfortunately, when I attempt to run a migration like this, I get the 
> following error:
>
> Mysql2::Error: BLOB/TEXT column 'id' used in key specification without a 
> key length
>
> The short question is, how do I get around this problem and still use 
> migrations?
>

It's always helpful when you run into issues like this to post a complete 
SQL log showing the query that causes the error.  Without that it is more 
difficult to diagnose the problem.

If I had to guess, the issue is that either the primary key constraint 
needs to be '(id(16))' and not '(id)' or Sequel is ignoring the :size 
option for the File generic type, probably the latter.  You could try 
dumping in database specific mode (-D) instead of database independent mode 
(-d) and see if that makes a difference.  Assuming the issue is that the 
:size option is being ignored, that may fix it.  Worst case scenario would 
be you have to write the CREATE TABLE SQL by hand for that table.

You should always question whether you really need to convert the existing 
schema into Sequel migration format, or if using Sequel's schema dumper is 
the best way to accomplish what you want.  Maybe just using mysql dump 
output and using raw SQL queries would be easier if you only intend to run 
on MySQL.  Unless you are attempting to convert to another database, you 
may be better off using mysql-specific tools.  Sequel's schema_dumper is a 
best-effort thing, it will never handle all cases.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/5qt0AQJDfMMJ.
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