Wrong file structure on migrate #1003

This commit is contained in:
Karel Pičman 2019-05-02 12:39:04 +02:00
parent f2e161c179
commit e4719ea5e6

View File

@ -28,7 +28,7 @@ class Dmsf144 < ActiveRecord::Migration[4.2]
end end
def up def up
#A dd our entity_type column (used with our entity type) # Add our entity_type column (used with our entity type)
add_column :dmsf_file_locks, :entity_type, :integer, null: true add_column :dmsf_file_locks, :entity_type, :integer, null: true
# Add our lock relevent columns (ENUM) - null (till we upgrade data) # Add our lock relevent columns (ENUM) - null (till we upgrade data)
add_column :dmsf_file_locks, :lock_type_cd, :integer, null: true add_column :dmsf_file_locks, :lock_type_cd, :integer, null: true
@ -72,7 +72,7 @@ class Dmsf144 < ActiveRecord::Migration[4.2]
# Not sure if this is the right place to do this, as its file manipulation, not database (strictly) # Not sure if this is the right place to do this, as its file manipulation, not database (strictly)
say 'Completing one-time file migration ...' say 'Completing one-time file migration ...'
begin begin
DmsfFileRevision.visible.find_each do |rev| DmsfFileRevision.find_each do |rev|
next unless rev.project next unless rev.project
existing = DmsfFile.storage_path.join rev.disk_filename existing = DmsfFile.storage_path.join rev.disk_filename
new_path = rev.disk_file(false) new_path = rev.disk_file(false)
@ -120,7 +120,7 @@ class Dmsf144 < ActiveRecord::Migration[4.2]
# Not sure if this is the right place to do this, as its file manipulation, not database (stricly) # Not sure if this is the right place to do this, as its file manipulation, not database (stricly)
begin begin
say 'restoring old file-structure' say 'restoring old file-structure'
DmsfFileRevision.visible.find_each do |rev| DmsfFileRevision.find_each do |rev|
next unless rev.project next unless rev.project
project = rev.project.identifier.gsub(/[^\w\.\-]/, '_') project = rev.project.identifier.gsub(/[^\w\.\-]/, '_')
existing = DmsfFile.storage_path.join("p_#{project}/#{rev.disk_filename}") existing = DmsfFile.storage_path.join("p_#{project}/#{rev.disk_filename}")