Sha256: 007cf8f58cef49b6b009e1289bb2e403ec3ddfa805665371a3a6a71b28d6c0b6

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

###
# CreateLikes class
#
# This class defines the 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 lib/generators/like_system/templates/migration.rb
like_system-0.0.8 lib/generators/like_system/templates/migration.rb
like_system-0.0.7 lib/generators/like_system/templates/migration.rb
like_system-0.0.6 lib/generators/like_system/templates/migration.rb