diaspora/db/migrate/20111011194702_comment_anything.rb
2011-10-16 13:58:35 +02:00

18 lines
500 B
Ruby

class CommentAnything < ActiveRecord::Migration
def self.up
remove_foreign_key :comments, :posts
remove_index :comments, :post_id
change_table :comments do |t|
t.rename :post_id, :commentable_id
t.string :commentable_type, :default => 'Post', :null => false
end
end
def self.down
rename_column :comments, :commentable_id, :post_id
add_foreign_key :comments, :posts
add_index :comments, :post_id
remove_column :comments, :commentable_type
end
end