Sha256: c06b0ebda9c595cc9ef2662affc5029455f3da00754c12b6c0cfcc077c28a298

Contents?: true

Size: 788 Bytes

Versions: 4

Compression:

Stored size: 788 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_emotional_and_emotive'
  end

  def down
    drop_table :emotions
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
emotions-0.1.6 lib/generators/emotions/templates/migration.rb
emotions-0.1.5 lib/generators/emotions/templates/migration.rb
emotions-0.1.4 lib/generators/emotions/templates/migration.rb
emotions-0.1.3 lib/generators/emotions/templates/migration.rb