Sha256: 7d9821d6ff11e703ae75bf4124527146ed70ef1689ce386b500f27872e30051f

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

###
# CreateFollows class
#
# This class defines the test create follows migration in follow system
###
class CreateFollows < ActiveRecord::Migration[5.0]
  ###
  # Changes the database
  ###
  def change
    ###
    # Follows table creation
    ###
    create_table :follows do |t|
      ###
      # Followee id field and followee type field definition
      ###
      t.references :followee, polymorphic: true

      ###
      # Follower id fiel and follower type field definition
      ###
      t.references :follower, polymorphic: true

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

    ###
    # Follows table followee id field and followee type field index addition
    ###
    add_index :follows, [:followee_id, :followee_type], name: "follows_followee_idx"

    ###
    # Follows table follower id field and follower type field index addition
    ###
    add_index :follows, [:follower_id, :follower_type], name: "follows_follower_idx"

    ###
    # Follows table followee id field and followee type field and follower id field and follower type field unique index addition
    ###
    add_index :follows, [:followee_id, :followee_type, :follower_id, :follower_type], name: "follows_followee_follower_idx", unique: true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
follow_system-0.2.0 spec/db/migrate/20140926000000_create_follows.rb