Sha256: 88582c9f7a27ed02a9492d51a16a91dbe4fff7c27fb7cb00d13170543c4e3cde

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

###
# CreateFollows class
#
# This class defines the test create follows migration in follow system
###
class CreateFollows < ActiveRecord::Migration
  ###
  # 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

4 entries across 4 versions & 1 rubygems

Version Path
follow_system-0.0.9 spec/db/migrate/20140926000000_create_follows.rb
follow_system-0.0.8 spec/db/migrate/20140926000000_create_follows.rb
follow_system-0.0.7 spec/db/migrate/20140926000000_create_follows.rb
follow_system-0.0.6 spec/db/migrate/20140926000000_create_follows.rb