Sha256: 1bf12f67f1f1731bbb5383f0c6a9e153ea2428ac8faa0b89626438c26d123af0

Contents?: true

Size: 774 Bytes

Versions: 5

Compression:

Stored size: 774 Bytes

Contents

class AddEmotions < ActiveRecord::Migration
  def up
    create_table :emotions do |t|
      # The emotional model
      t.references :emotional, polymorphic: true

      # The emotive model
      t.references :emotive, polymorphic: true

      # The type of emotion
      t.string :emotion

      t.timestamps
    end

    add_index :emotions, [:emotional_type, :emotional_id, :emotive_type, :emotive_id, :emotion], unique: true, name: 'index_emotions_by_emotional_emotive_and_emotion'
    add_index :emotions, [:emotional_type, :emotional_id, :emotive_type, :emotive_id], name: 'index_emotions_by_emotional_and_emotive'
    add_index :emotions, [:emotive_type, :emotive_id, :emotion], name: 'index_emotions_by_emotive'
  end

  def down
    drop_table :emotions
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
emotions-0.3 lib/generators/emotions/templates/migration.rb
emotions-0.2.2 lib/generators/emotions/templates/migration.rb
emotions-0.2.1 lib/generators/emotions/templates/migration.rb
emotions-0.2 lib/generators/emotions/templates/migration.rb
emotions-0.1.7 lib/generators/emotions/templates/migration.rb