Files migration once more
This commit is contained in:
parent
db1dd717de
commit
478bac0f69
@ -36,31 +36,31 @@ class MigrateDocuments < ActiveRecord::Migration
|
|||||||
folder = self.storage_base_path(dmsf_file_revision)
|
folder = self.storage_base_path(dmsf_file_revision)
|
||||||
Dir.rmdir(folder) if (folder && (Dir.entries(folder).size == 2))
|
Dir.rmdir(folder) if (folder && (Dir.entries(folder).size == 2))
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: #{e.message}"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: #{e.message}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: Target '#{target}' exists"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: Target '#{target}' exists"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: target = nil"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: target = nil"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: Origin '#{origin}' doesn't exist"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: Origin '#{origin}' doesn't exist"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: disk_file = nil"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: disk_file = nil"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFile ID #{dmsf_file_revision.dmsf_file.id}: project = nil"
|
say "DmsfFile ID #{dmsf_file_revision.dmsf_file.id}: project = nil"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: dmsf_file = nil"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: dmsf_file = nil"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
# Migrate all documents from dmsf/p_{project identifier} to dmsf/{year}/{month}
|
# Migrate all documents from dmsf/{year}/{month} to dmsf/p_{project identifier}
|
||||||
DmsfFileRevision.find_each do |dmsf_file_revision|
|
DmsfFileRevision.find_each do |dmsf_file_revision|
|
||||||
if dmsf_file_revision.dmsf_file
|
if dmsf_file_revision.dmsf_file
|
||||||
if dmsf_file_revision.dmsf_file.project
|
if dmsf_file_revision.dmsf_file.project
|
||||||
@ -75,25 +75,25 @@ class MigrateDocuments < ActiveRecord::Migration
|
|||||||
folder = dmsf_file_revision.storage_base_path
|
folder = dmsf_file_revision.storage_base_path
|
||||||
Dir.rmdir(folder) if (folder && (Dir.entries(folder).size == 2))
|
Dir.rmdir(folder) if (folder && (Dir.entries(folder).size == 2))
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: #{e.message}"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: #{e.message}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: Target '#{target}' exists"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: Target '#{target}' exists"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: target = nil"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: target = nil"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: Origin '#{origin}' doesn't exist"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: Origin '#{origin}' doesn't exist"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: disk_file = nil"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: disk_file = nil"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFile ID #{dmsf_file_revision.dmsf_file.id}: project = nil"
|
say "DmsfFile ID #{dmsf_file_revision.dmsf_file.id}: project = nil"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.error "DmsfFileRevisions ID #{dmsf_file_revision.id}: dmsf_file = nil"
|
say "DmsfFileRevisions ID #{dmsf_file_revision.id}: dmsf_file = nil"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
41
db/migrate/20170718132801_migrate_documents2.rb
Normal file
41
db/migrate/20170718132801_migrate_documents2.rb
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
#
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011-17 Karel Pičman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
require File.expand_path('../20170418104901_migrate_documents', __FILE__)
|
||||||
|
|
||||||
|
class MigrateDocuments2 < ActiveRecord::Migration
|
||||||
|
|
||||||
|
# Copy of 20170418104901_migrate_documents.rb
|
||||||
|
# Due to an error it might have happened that not all files have been migrated.
|
||||||
|
# So, let's run the migration again
|
||||||
|
|
||||||
|
def up
|
||||||
|
# Migrate all documents from dmsf/p_{project identifier} to dmsf/{year}/{month}
|
||||||
|
migration = MigrateDocuments.new
|
||||||
|
migration.up
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
# Migrate all documents from dmsf/{year}/{month} to dmsf/p_{project identifier}
|
||||||
|
migration = MigrateDocuments.new
|
||||||
|
migration.down
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user