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.

sexier migrations for edge post 6667

#5

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

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

State: hold
Milestone: none
Assigned to: Chris Wanstrath Chris Wanstrath

Activity

  1. Chris Wanstrath
    Chris Wanstrath
    • 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.

    May 23rd, 2007 @ 06:47 PM

  2. Chris Wanstrath
    Chris Wanstrath

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

    May 23rd, 2007 @ 06:47 PM

  3. Andrew Kuklewicz
    Andrew Kuklewicz
    • 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

    May 23rd, 2007 @ 06:47 PM

  4. Chris Wanstrath
    Chris Wanstrath

    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?

    May 23rd, 2007 @ 06:47 PM

  5. Andrew Kuklewicz
    Andrew Kuklewicz

    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).

    May 23rd, 2007 @ 06:47 PM

  6. Chris Wanstrath
    Chris Wanstrath
    • 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.

    May 23rd, 2007 @ 06:47 PM

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.