Sha256: e2f1a8584a25ab4af2b5a38d25b32aea8f26bf342c218c5f09be0294e0616674

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

###
# CreateLikes class
#
# This class defines the test create likes migration in like system
###
class CreateLikes < ActiveRecord::Migration[5.0]
  ###
  # 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

2 entries across 2 versions & 1 rubygems

Version Path
like_system-0.1.1 spec/db/migrate/20140926000000_create_likes.rb
like_system-0.1.0 spec/db/migrate/20140926000000_create_likes.rb