class AddUploadsCountToComments < ActiveRecord::Migration
  def self.up
    add_column :comments, :uploads_count, :integer, :default => 0
    Comment.update_all "uploads_count = (SELECT COUNT(*) FROM uploads, comments WHERE uploads.comment_id = comments.id AND uploads.deleted_at IS NULL)", "deleted_at IS NULL"
  end

  def self.down
    remove_column :comments, :uploads_count
  end
end

class AddUploadsCountToComments < ActiveRecord::Migration
  def self.up
    add_column :comments, :uploads_count, :integer, :default => 0
    Comment.update_all "uploads_count = (SELECT COUNT(*) FROM `uploads` WHERE uploads.comment_id = comments.id AND uploads.deleted_at IS NULL)", "deleted_at IS NULL"
  end

  def self.down
    remove_column :comments, :uploads_count
  end
end

Revert "fix migration for postgresql"
Revert "fix migration for postgresql"

This reverts commit 653731f7c0a0b1d40e20bc1ac10dc3b203a3de5e.
