Sha256: 28d254a801874040f5a13b7855dc6ab1184b2d0a483ac7ee44fc5e4442ee1eb2

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

###
# CreateMentions class
#
# This class defines the test create mentions migration in mention system
###
class CreateMentions < ActiveRecord::Migration[5.0]
  ###
  # Changes the database
  ###
  def change
    ###
    # Mentions table creation
    ###
    create_table :mentions do |t|
      ###
      # Mentionee id field and mentionee type field definition
      ###
      t.references :mentionee, polymorphic: true

      ###
      # Mentioner id fiel and mentioner type field definition
      ###
      t.references :mentioner, polymorphic: true

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

    ###
    # Mentions table mentionee id field and mentionee type field index addition
    ###
    add_index :mentions, [:mentionee_id, :mentionee_type], name: "mentions_mentionee_idx"

    ###
    # Mentions table mentioner id field and mentioner type field index addition
    ###
    add_index :mentions, [:mentioner_id, :mentioner_type], name: "mentions_mentioner_idx"

    ###
    # Mentions table mentionee id field and mentionee type field and mentioner id field and mentioner type field unique index addition
    ###
    add_index :mentions, [:mentionee_id, :mentionee_type, :mentioner_id, :mentioner_type], name: "mentions_mentionee_mentioner_idx", unique: true
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mention_system-0.3.1 spec/db/migrate/20140926000000_create_mentions.rb
mention_system-0.3.0 spec/db/migrate/20140926000000_create_mentions.rb
mention_system-0.2.0 spec/db/migrate/20140926000000_create_mentions.rb