Added migration to warn on existing files attached to projects and versions

pull/310/head
Sebastian Schuster 11 years ago committed by Christian Ratz
parent cbcaa6fe64
commit c94efc290b
  1. 17
      db/migrate/20130807141542_remove_files_attached_to_projects_and_versions.rb

@ -0,0 +1,17 @@
class RemoveFilesAttachedToProjectsAndVersions < ActiveRecord::Migration
def up
if Attachment.where(:container_type => ['Version','Project']).any?
raise "There are still attachments attached to Versions or Projects, please remove them."
end
#undocument this code if you want do delete all existing files attached to projects and versions
#path = Rails.root.to_s + '/files/'
#Attachment.where(:container_type => ['Version','Project']).each do |attachment|
# file = path + attachment.disk_filename
# File.delete(file) if File.exists?(file)
#end
#Attachment.where(:container_type => ['Version','Project']).delete_all
end
def down
end
end
Loading…
Cancel
Save