Skip to content

Instantly share code, notes, and snippets.

@abdul-shajin
Created December 5, 2011 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdul-shajin/1433226 to your computer and use it in GitHub Desktop.
Save abdul-shajin/1433226 to your computer and use it in GitHub Desktop.
Add index with other foreign key
class ActsAsFollowerMigration < ActiveRecord::Migration
def self.up
create_table :follows, :force => true do |t|
t.references :followable, :polymorphic => true, :null => false
t.references :follower, :polymorphic => true, :null => false
t.boolean :blocked, :default => false, :null => false
t.timestamps
end
add_index :follows, ["follower_id", "follower_type"], :name => "fk_follows"
add_index :follows, ["followable_id", "followable_type"], :name => "fk_followables"
end
def self.down
drop_table :follows
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment