#708 ✓resolved
Betelgeuse

Make index generation pay attention to DB limits

Reported by Betelgeuse | April 26th, 2010 @ 10:54 AM | in Hobo 1.1

rake aborted!
An error has occurred, this and all later migrations canceled:

Input string is longer than NAMEDATALEN-1 (63)

(See full trace by running task with --trace)

Code causing this:

index [:some_long_id, :another_long_id], :unique => true

Comments and changes to this ticket

  • Bryan Larsen

    Bryan Larsen May 19th, 2010 @ 06:15 PM

    • State changed from “new” to “wontfix”

    Unfortunately, this ia a bug in Rails itself, which generates insanely long index names. This is actually a much more significant problem with Oracle, which has a much shorter limit.

    To work around this issue, you'll need to supply an explicit name:

     index [:some_long_id, :another_long_id], :unique => true, :name => "some_index_name"
    
  • Matt Jones

    Matt Jones May 20th, 2010 @ 02:11 AM

    • Milestone set to Hobo 1.1
    • Tag changed from migration-generator to enhancement, migration-generator
    • State changed from “wontfix” to “open”
    • Title changed from “Hobo migration generator generating too long index names for PostgreSQL” to “Make index generation pay attention to DB limits”
    • Assigned user set to “Matt Jones”

    Actually, we can now fix this! Yay! Rails just accepted this patch so we actually have a shot at knowing how long an index name can be before bad things happen.

    Or at the very least, the new add_index code whines but doesn't die when the name is too long.

    We'll need to figure out the best UI for this - should the migration generator ask, or just warn? There's also the mess from developing on one DB and deploying on another with different limits, but that may just be a "enter at your own risk" setup.

  • Betelgeuse

    Betelgeuse May 20th, 2010 @ 07:22 AM

    There could be a configuration option specifying what all databases will be supported by the project.

  • Matt Jones
  • Matt Jones

    Matt Jones September 21st, 2011 @ 04:15 PM

    • State changed from “open” to “resolved”

    I've added code to 1.3 do the checks. I'm not 100% satisfied with the reporting aspect, as printing to stderr isn't particularly noticeable (especially since the message appears right before the migration preview), but I can't think of any other way to report the issue...

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 ยป

Referenced by

Pages