Class: LikesMigration

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/templates/likes_migration.rb

Instance Method Summary collapse

Instance Method Details

#changeObject


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/templates/likes_migration.rb', line 2

def change
  create_table :likes do |t|
    #this table must have xxx_identity, xxx_id, xxx_type 3 columns
    t.string :likeable_identity, null: false
    t.references :likeable, :polymorphic => true, :null => false

    #you maybe need change this column
    t.references :user

    t.timestamps
  end

  #indexes
  #add_index :likes, [:user_id, :likeable_id, :likeable_type], :unique => true
  #add_index :likes, :user_id
end