Class: InstallInboxes

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/inboxes/templates/install.rb

Class Method Summary collapse

Class Method Details

.downObject



25
26
27
28
29
# File 'lib/generators/inboxes/templates/install.rb', line 25

def self.down
  drop_table :speakers
  drop_table :discussions
  drop_table :messages
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/inboxes/templates/install.rb', line 2

def self.up
  create_table :discussions do |t|
    t.integer :messages_count, :default => 0 # counter cache
    t.references :discussable, :polymorphic => true
    t.timestamps
  end

  create_table :messages do |t|
    t.references :user
    t.references :discussion
    t.text :body

    t.timestamps
  end

  create_table :speakers do |t|
    t.references :user
    t.references :discussion

    t.timestamps
  end
end