Sha256: 354e1a2a887809f662ba74dced5c838994c91b0419367f1c3a16cbab30ec7594

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

###
# CreateLikes class
#
# This class defines the test create likes migration in like system
###
class CreateLikes < ActiveRecord::Migration
  ###
  # Changes the database
  ###
  def change
    ###
    # Likes table creation
    ###
    create_table :likes do |t|
      ###
      # Likee id field and likee type field definition
      ###
      t.references :likee, polymorphic: true

      ###
      # Liker id fiel and liker type field definition
      ###
      t.references :liker, polymorphic: true

      ###
      # Timestamps fields definition
      ###
      t.timestamps null: false
    end

    ###
    # Likes table likee id field and likee type field index addition
    ###
    add_index :likes, [:likee_id, :likee_type], name: "likes_likee_idx"

    ###
    # Likes table liker id field and liker type field index addition
    ###
    add_index :likes, [:liker_id, :liker_type], name: "likes_liker_idx"

    ###
    # Likes table likee id field and likee type field and liker id field and liker type field unique index addition
    ###
    add_index :likes, [:likee_id, :likee_type, :liker_id, :liker_type], name: "likes_likee_liker_idx", unique: true
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
like_system-0.0.9 spec/db/migrate/20140926000000_create_likes.rb
like_system-0.0.8 spec/db/migrate/20140926000000_create_likes.rb
like_system-0.0.7 spec/db/migrate/20140926000000_create_likes.rb
like_system-0.0.6 spec/db/migrate/20140926000000_create_likes.rb