Class: PopularMigration
- Inherits:
-
ActiveRecord::Migration
- Object
- ActiveRecord::Migration
- PopularMigration
- Defined in:
- lib/generators/popular/migration/templates/active_record/migration.rb
Instance Method Summary collapse
Instance Method Details
#down ⇒ Object
15 16 17 |
# File 'lib/generators/popular/migration/templates/active_record/migration.rb', line 15 def down drop_table :friendships end |
#up ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/generators/popular/migration/templates/active_record/migration.rb', line 2 def up create_table :friendships do |t| t.references :popular_model, polymorphic: true t.references :friend, polymorphic: true t. end add_index :friendships, [:popular_model_id, :popular_model_type] add_index :friendships, [:friend_id, :friend_type] end |