mirror of
https://github.com/internetee/registry.git
synced 2025-08-12 12:39:34 +02:00
Add logging
This commit is contained in:
parent
3d1bcb305b
commit
e6648e03bf
1 changed files with 10 additions and 1 deletions
|
@ -2,7 +2,7 @@ class AddMissingData < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
return if Rails.env == 'development'
|
return if Rails.env == 'development'
|
||||||
return if Rails.env == 'test'
|
return if Rails.env == 'test'
|
||||||
|
puts 'GENERATING ACCOUNTS'
|
||||||
Registrar.all.each do |x|
|
Registrar.all.each do |x|
|
||||||
Account.create(
|
Account.create(
|
||||||
registrar_id: x.id,
|
registrar_id: x.id,
|
||||||
|
@ -12,25 +12,34 @@ class AddMissingData < ActiveRecord::Migration
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
puts 'GENERATING REFERENCE NUMBERS'
|
||||||
|
|
||||||
Registrar.all.each do |x|
|
Registrar.all.each do |x|
|
||||||
x.generate_iso_11649_reference_no
|
x.generate_iso_11649_reference_no
|
||||||
x.save
|
x.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
puts 'SAVING LEGAL DOCUMENTS'
|
||||||
|
|
||||||
LegalDocument.all.each do |x|
|
LegalDocument.all.each do |x|
|
||||||
path = nil
|
path = nil
|
||||||
|
i = 0
|
||||||
loop do
|
loop do
|
||||||
|
puts "LOOPING #{i}"
|
||||||
|
i += 1
|
||||||
rand = SecureRandom.random_number.to_s.last(4)
|
rand = SecureRandom.random_number.to_s.last(4)
|
||||||
next if rand.to_i == 0 || rand.length < 4
|
next if rand.to_i == 0 || rand.length < 4
|
||||||
path = "#{ENV['legal_documents_dir']}/#{Time.zone.now.to_formatted_s(:number)}_#{rand}.#{x.document_type}"
|
path = "#{ENV['legal_documents_dir']}/#{Time.zone.now.to_formatted_s(:number)}_#{rand}.#{x.document_type}"
|
||||||
break unless File.file?(path)
|
break unless File.file?(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
puts "SAVING LEGAL DOCUMENT #{x.id}"
|
||||||
body = x.read_attribute('body')
|
body = x.read_attribute('body')
|
||||||
File.open(path, 'wb') { |f| f.write(Base64.decode64(body)) }
|
File.open(path, 'wb') { |f| f.write(Base64.decode64(body)) }
|
||||||
x.update_column('path', path)
|
x.update_column('path', path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
puts 'REMOVING COLUMN'
|
||||||
remove_column :legal_documents, :body, :text
|
remove_column :legal_documents, :body, :text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue