Class: CreateModerations

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/has_moderated/install/templates/migrations/1_create_moderations.rb

Class Method Summary collapse

Class Method Details

.downObject



17
18
19
# File 'lib/generators/has_moderated/install/templates/migrations/1_create_moderations.rb', line 17

def self.down
  drop_table :moderations
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/generators/has_moderated/install/templates/migrations/1_create_moderations.rb', line 2

def self.up
  if table_exists? :moderations # for upgrading
    if Moderation.count > 0
      raise "Moderations table must be empty before upgrading has_moderated!"
    end
    drop_table :moderations
  end
  create_table "moderations" do |t|
    t.integer "moderatable_id",  :null => true
    t.string  "moderatable_type",  :null => true
    t.text    "data",  :null => false
    t.timestamps
  end
end