Class: CreateMakeWatchableTables

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

Class Method Summary collapse

Class Method Details

.downObject



16
17
18
19
20
21
# File 'lib/generators/make_watchable/templates/migration.rb', line 16

def self.down
  remove_index :watchings, :column => [:watchable_type, :watchable_id]
  remove_index :watchings, :name => "access_watchings"
  
  drop_table :watchings
end

.upObject



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

def self.up
   create_table :watchings do |t|
     t.string :watchable_type
     t.integer :watchable_id
     t.string :watcher_type
     t.integer :watcher_id

     t.timestamps
  end

  add_index :watchings, [:watchable_type, :watchable_id]
  add_index :watchings, [:watcher_type, :watcher_id, :watchable_type, :watchable_id], :name => "access_watchings"
end