Class: CreateFlags

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

Class Method Summary collapse

Class Method Details

.downObject



16
17
18
# File 'lib/generators/flags/templates/create_flags.rb', line 16

def self.down
  drop_table :flags
end

.upObject



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

def self.up
  create_table :flags do |t|
    t.text :comment
    t.references :flaggable, :polymorphic => true
    t.references :user
    # other roles could be spam, inappropriate, etc.
    t.string :role, :default => "abuse"
    t.timestamps
  end

  add_index :flags, [:flaggable_type, :flaggable_id]
  add_index :flags, :user_id
end