Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Add support for index length in MySQL adapter and schema dumper

#734

Add support for index length in MySQL adapter and schema dumper.

Using this patch you can now define a length for you indices:

add_index(:people, :col_name, :length => 5) add_index(:people, [:col_name, :other_col], :length => {:col_name => 5, :other_col => 1})

This will result in the following SQL:

CREATE INDEX index_people_on_col_name ON people (col_name(5)) CREATE INDEX index_people_on_col_name ON people (col_name(5), other_col(1))

The schema dumper will honor the index length so that schema.rb will be correct and keep track of index length.

See http://github.com/jweiss/rails/c...

http://github.com/jweiss/rails/c...

http://github.com/jweiss/rails/c...

http://github.com/jweiss/rails/c...

Or the attached patch.

Provided by Christoph Bünte (info@christophbuente.de), Enno Brehm (enno.brehm@gmail.com) Jonathan Weiss (jw@innerewut.de)

Reported by Jonathan Weiss · August 14th, 2008 @ 09:07 AM

State: wontfix
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Jonathan Weiss
  2. Jonathan Weiss
  3. Pratik
    Pratik
    • Assigned user set to Pratik
    • State changed from new to wontfix

    I think this is a better fit for a plugin. I asked around and no one really ever needed to use this feature. Having said that, if you want Rails to provide any hooks for pluginizing this, patches will be most welcome.

    If you find people who need this feature, please have them post +1 here and we can re-evaluate the patch.

    Thanks.

    October 7th, 2008 @ 03:56 PM

  4. Ricky
    Ricky

    +1 on this. This sort of thing seems to be required whenever you create an index on a blob-like field (text/binary/etc).

    November 3rd, 2008 @ 07:25 AM

  5. dkindlund
    dkindlund
    1. Have you seen the plugin-version of this? http://dev.rubyonrails.org/ticke...

    Also, even though the plugin works, it fails to write the correct length information to the db/schema.rb file. So, when you run something like "rake tests:unit", then the corresponding db/schema.rb file loads but fails on the malformed index (i.e., "no length specified").

    So, if you use that plugin as a basis, is there any way to add the "db/schema.rb" creation logic to the plugin?

    March 2nd, 2009 @ 10:06 PM

  6. ...Paul
    ...Paul

    You can uncomment this line from config/environment.rb

    config.active_record.schema_format = :sql

    Then rake tests will clone_structure rather than just clone. Reference comment on Bug #74.

    September 6th, 2009 @ 09:26 PM