Sha256: 7cd679b570f5d7a81fc29eeb7405b07dd73dd0542372bf1c7c425f92fa23e9a0

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

###
# CreateBookmarks class
#
# This class defines the test create bookmarks migration in bookmark system
###
class CreateBookmarks < ActiveRecord::Migration[5.0]
  ###
  # Changes the database
  ###
  def change
    ###
    # Bookmarks table creation
    ###
    create_table :bookmarks do |t|
      ###
      # Bookmarkee id field and bookmarkee type field definition
      ###
      t.references :bookmarkee, polymorphic: true

      ###
      # Bookmarker id fiel and bookmarker type field definition
      ###
      t.references :bookmarker, polymorphic: true

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

    ###
    # Bookmarks table bookmarkee id field and bookmarkee type field index addition
    ###
    add_index :bookmarks, [:bookmarkee_id, :bookmarkee_type], name: "bookmarks_bookmarkee_idx"

    ###
    # Bookmarks table bookmarker id field and bookmarker type field index addition
    ###
    add_index :bookmarks, [:bookmarker_id, :bookmarker_type], name: "bookmarks_bookmarker_idx"

    ###
    # Bookmarks table bookmarkee id field and bookmarkee type field and bookmarker id field and bookmarker type field unique index addition
    ###
    add_index :bookmarks, [:bookmarkee_id, :bookmarkee_type, :bookmarker_id, :bookmarker_type], name: "bookmarks_bookmarkee_bookmarker_idx", unique: true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bookmark_system-0.1.1 spec/db/migrate/20140926000000_create_bookmarks.rb
bookmark_system-0.1.0 spec/db/migrate/20140926000000_create_bookmarks.rb