Skip to content

Instantly share code, notes, and snippets.

@oki
Created January 28, 2009 21:23
Show Gist options
  • Select an option

  • Save oki/54200 to your computer and use it in GitHub Desktop.

Select an option

Save oki/54200 to your computer and use it in GitHub Desktop.
class AddIndexes < ActiveRecord::Migration
def self.up
change_table(:songs) do |t|
t.index(:hash_id, :unique => true)
end
change_table(:record_songs) do |t|
t.index([:song_id, :record_id])
end
end
def self.down
change_table(:songs) do |t|
t.remove_index :column => :hash_id
end
change_table(:record_songs) do |t|
t.remove_index :column => [:song_id, :record_id]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment