Class: CreateMessagesTable

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/has_mailbox/migration/templates/create_messages_table.rb

Class Method Summary collapse

Class Method Details

.downObject



16
17
18
# File 'lib/generators/has_mailbox/migration/templates/create_messages_table.rb', line 16

def self.down
  drop_table :messages
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/generators/has_mailbox/migration/templates/create_messages_table.rb', line 2

def self.up
  create_table :messages do |t|
    	t.references :received_messageable, :polymorphic => true
t.integer :sender_id
t.string :subject
t.text :body
t.boolean :opened, :default => false
t.boolean :deleted, :default => false
t.timestamps
  end

  add_index :messages, [:received_messageable_id, :sender_id], :name => "inbox_idx"
end