class CreateMessageRecipients < ActiveRecord::Migration
  def self.up
    create_table :message_recipients do |t|
      t.references :message, :null => false
      t.references :receiver, :polymorphic => true, :null => false
      t.string :kind, :null => false, :length => 20
      t.integer :position
      t.string :state, :null => false, :length => 10
      t.datetime :hidden_at
    end
    add_index :message_recipients, [:receiver_type, :receiver_id]
    add_index :message_recipients, [:message_id, :kind, :position], :unique => true
  end
  
  def self.down
    drop_table :message_recipients
  end
end
