#5 ✓hold
Jim Morris

sexier migrations for edge post 6667

Reported by Jim Morris | May 23rd, 2007 @ 06:47 PM

This pastie has a patch against the current release of sexy_migrations which adds an option :idx. This will create an index for the column specified. index options can be passed in as a hash or a simple one with true.

eg
string :alias, :idx => {:unique => true} # creates a unique index on alias

integer :user, :idx => true # creates a simple index on user

foreign_key :user, :ref => :users, :idx => true # creates a foreign key constraint, and an index on user_id

It also has the foreign key constraints patch.

http://pastie.caboo.se/54051

Comments and changes to this ticket

  • Chris Wanstrath

    Chris Wanstrath May 23rd, 2007 @ 06:47 PM

    • State changed from “new” to “open”
    • Assigned user set to “Chris Wanstrath”

    I think I'd rather do the add_index inline for this feature, rather than doing it after the yield. Gonna look at doing this now.

  • Chris Wanstrath

    Chris Wanstrath May 23rd, 2007 @ 06:47 PM

    Can we clean this up some and use :index instead of :idx?

  • Andrew Kuklewicz

    Andrew Kuklewicz May 23rd, 2007 @ 06:47 PM

    • Title changed from “Add indexes to sexy_migrations” to “sexier migrations for edge post 6667”

    with the addition of changeset 6667, some of sexy migrations is all set, but the indices and fk stuff is not in there, so I updated the sexy migration code for a post 6667 world:

    http://pastie.caboo.se/63388

  • Chris Wanstrath

    Chris Wanstrath May 23rd, 2007 @ 06:47 PM

    I don't want to remove functionality from the plugin because some people may be running it on 1.1.x or 1.2.x and this patch would break their application, y'know?

  • Andrew Kuklewicz

    Andrew Kuklewicz May 23rd, 2007 @ 06:47 PM

    Thanks for taking a look

    I hear ya - I figure I'll keep working on an 'edge' version so that by the time edge becomes a legit release, it will be ready/used/tested - I didn't expect it to get patched yet.

    I guess another option is to make this into it's own plugin - but seriously, how many more migration plugins need to be out there :)

    In my latest version, I also added a 'sortable' method to create a 'position' integer column to support acts_as_list, and I'd add another to support acts_as_tree (with parent_id and fk to self) if I could think of a snappy method name (adopted! no, leafable!, no, parented!, maybe...crap this shouldn't be so hard).

  • Chris Wanstrath

    Chris Wanstrath May 23rd, 2007 @ 06:47 PM

    • State changed from “open” to “hold”

    I'm not against changing the edge version to not interfere with edge rails, maybe with a conditional around the method_missing definition or something.

    Anyway, closing until a diff or something is pasted.

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

Shared Ticket Bins

People watching this ticket

Attachments

Tags

Pages