From 350cae621ac9abc34f06a280e04e5caba73a26a1 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 29 Apr 2015 16:51:11 +0300 Subject: [PATCH] Remove data migrations --- db/migrate/20150410124724_create_accounts.rb | 4 ---- ...0150414092249_add_reference_no_to_registrar.rb | 5 ----- ...50415075408_fix_account_balances_to_decimal.rb | 5 ----- .../20150416080828_add_currency_to_account.rb | 2 -- ...20150417082723_create_versions_for_billing.rb} | 0 .../20150422132631_save_legal_docs_to_disk.rb | 15 --------------- .../20150423083308_add_number_to_invoices.rb | 1 - .../20150428075052_add_sum_cache_to_invoice.rb | 1 - 8 files changed, 33 deletions(-) rename db/migrate/{20150409082723_create_versions_for_billing.rb => 20150417082723_create_versions_for_billing.rb} (100%) diff --git a/db/migrate/20150410124724_create_accounts.rb b/db/migrate/20150410124724_create_accounts.rb index d630f0ef1..aa1a726bf 100644 --- a/db/migrate/20150410124724_create_accounts.rb +++ b/db/migrate/20150410124724_create_accounts.rb @@ -7,9 +7,5 @@ class CreateAccounts < ActiveRecord::Migration t.timestamps end - - Registrar.all.each do |x| - Account.create(registrar_id: x.id, account_type: Account::CASH) - end end end diff --git a/db/migrate/20150414092249_add_reference_no_to_registrar.rb b/db/migrate/20150414092249_add_reference_no_to_registrar.rb index d49720d0a..dcb762ab4 100644 --- a/db/migrate/20150414092249_add_reference_no_to_registrar.rb +++ b/db/migrate/20150414092249_add_reference_no_to_registrar.rb @@ -1,10 +1,5 @@ class AddReferenceNoToRegistrar < ActiveRecord::Migration def change add_column :registrars, :reference_no, :string - - Registrar.all.each do |x| - x.generate_iso_11649_reference_no - x.save - end end end diff --git a/db/migrate/20150415075408_fix_account_balances_to_decimal.rb b/db/migrate/20150415075408_fix_account_balances_to_decimal.rb index 8dbae0490..f86a657b9 100644 --- a/db/migrate/20150415075408_fix_account_balances_to_decimal.rb +++ b/db/migrate/20150415075408_fix_account_balances_to_decimal.rb @@ -1,10 +1,5 @@ class FixAccountBalancesToDecimal < ActiveRecord::Migration def change - Account.all.each do |x| - x.balance = 0.0 unless x.balance - x.save - end - change_column :accounts, :balance, :decimal, null: false, default: 0 end end diff --git a/db/migrate/20150416080828_add_currency_to_account.rb b/db/migrate/20150416080828_add_currency_to_account.rb index 5f67af359..b73ae0415 100644 --- a/db/migrate/20150416080828_add_currency_to_account.rb +++ b/db/migrate/20150416080828_add_currency_to_account.rb @@ -1,7 +1,5 @@ class AddCurrencyToAccount < ActiveRecord::Migration def change add_column :accounts, :currency, :string - - Account.update_all(currency: 'EUR') end end diff --git a/db/migrate/20150409082723_create_versions_for_billing.rb b/db/migrate/20150417082723_create_versions_for_billing.rb similarity index 100% rename from db/migrate/20150409082723_create_versions_for_billing.rb rename to db/migrate/20150417082723_create_versions_for_billing.rb diff --git a/db/migrate/20150422132631_save_legal_docs_to_disk.rb b/db/migrate/20150422132631_save_legal_docs_to_disk.rb index d0e184163..03b444812 100644 --- a/db/migrate/20150422132631_save_legal_docs_to_disk.rb +++ b/db/migrate/20150422132631_save_legal_docs_to_disk.rb @@ -1,20 +1,5 @@ class SaveLegalDocsToDisk < ActiveRecord::Migration def change add_column :legal_documents, :path, :string - LegalDocument.all.each do |x| - path = nil - loop do - rand = SecureRandom.random_number.to_s.last(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}" - break unless File.file?(path) - end - - body = x.read_attribute('body') - File.open(path, 'wb') { |f| f.write(Base64.decode64(body)) } - x.update_column('path', path) - end - - remove_column :legal_documents, :body, :text end end diff --git a/db/migrate/20150423083308_add_number_to_invoices.rb b/db/migrate/20150423083308_add_number_to_invoices.rb index 6e0f5ed4a..6659c2e77 100644 --- a/db/migrate/20150423083308_add_number_to_invoices.rb +++ b/db/migrate/20150423083308_add_number_to_invoices.rb @@ -1,6 +1,5 @@ class AddNumberToInvoices < ActiveRecord::Migration def change add_column :invoices, :number, :integer - Invoice.all.each(&:save) end end diff --git a/db/migrate/20150428075052_add_sum_cache_to_invoice.rb b/db/migrate/20150428075052_add_sum_cache_to_invoice.rb index 6706892ef..0a8b49fcc 100644 --- a/db/migrate/20150428075052_add_sum_cache_to_invoice.rb +++ b/db/migrate/20150428075052_add_sum_cache_to_invoice.rb @@ -1,6 +1,5 @@ class AddSumCacheToInvoice < ActiveRecord::Migration def change add_column :invoices, :sum_cache, :decimal - Invoice.all.each(&:save) end end