From b10f62f539796bc374ff5dfa8bf903e8f193f90c Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Mon, 1 Jun 2015 11:41:42 +0300 Subject: [PATCH] Added dedicated data migartion #2659 --- CHANGELOG.md | 4 ++++ Gemfile | 3 +++ Gemfile.lock | 9 +++++++++ .../20150601083516_add_cert_common_name.rb} | 8 ++++++-- .../20150601083800_add_cert_md5.rb} | 8 ++++++-- 5 files changed, 28 insertions(+), 4 deletions(-) rename db/{migrate/20150525075550_update_certs_add_cn_from_csr.rb => data/20150601083516_add_cert_common_name.rb} (66%) rename db/{migrate/20150522164020_update_certs.rb => data/20150601083800_add_cert_md5.rb} (85%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86ae1a35a..04d4a0053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +01.06.2015 + +* Added separate data update, all data migration locate at db/data, more info 'rake -T data' + 29.05.2015 * Removed old 'iptables_counter_update_command' and added 'iptables_counter_enabled' diff --git a/Gemfile b/Gemfile index 878dc62bf..7a947bb76 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,9 @@ gem 'isikukood' # for EE-id validation # deploy gem 'whenever', '~> 0.9.4', require: false +gem 'data_migrate', + github: 'gitlabeu/data_migrate', + ref: '35d22b09ff37a4e9d61ab326ad5d8eb0edf1fc81' # monitors gem 'newrelic_rpm', '~> 3.9.9.275' diff --git a/Gemfile.lock b/Gemfile.lock index 9b674285f..dbc311d2e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,6 +8,14 @@ GIT activesupport (>= 3.0, < 6.0) request_store (~> 1.1.0) +GIT + remote: git://github.com/gitlabeu/data_migrate.git + revision: 35d22b09ff37a4e9d61ab326ad5d8eb0edf1fc81 + ref: 35d22b09ff37a4e9d61ab326ad5d8eb0edf1fc81 + specs: + data_migrate (1.3.0) + rails (>= 4.1.0) + GIT remote: git://github.com/gitlabeu/epp.git revision: 505c3f2739eb1da918e54111aecfb138a822739d @@ -507,6 +515,7 @@ DEPENDENCIES coderay (~> 1.1.0) coffee-rails (~> 4.1.0) countries (~> 0.10.0) + data_migrate! database_cleaner (~> 1.3.0) deep_cloneable (~> 2.1.1) devise (~> 3.4.1) diff --git a/db/migrate/20150525075550_update_certs_add_cn_from_csr.rb b/db/data/20150601083516_add_cert_common_name.rb similarity index 66% rename from db/migrate/20150525075550_update_certs_add_cn_from_csr.rb rename to db/data/20150601083516_add_cert_common_name.rb index ab56b0c8a..ef401b871 100644 --- a/db/migrate/20150525075550_update_certs_add_cn_from_csr.rb +++ b/db/data/20150601083516_add_cert_common_name.rb @@ -1,5 +1,5 @@ -class UpdateCertsAddCnFromCsr < ActiveRecord::Migration - def change +class AddCertCommonName < ActiveRecord::Migration + def self.up Certificate.all.each do |x| if x.crt.blank? && x.csr.present? pc = x.parsed_csr.try(:subject).try(:to_s) || '' @@ -9,4 +9,8 @@ class UpdateCertsAddCnFromCsr < ActiveRecord::Migration x.save end end + + def self.down + raise ActiveRecord::IrreversibleMigration + end end diff --git a/db/migrate/20150522164020_update_certs.rb b/db/data/20150601083800_add_cert_md5.rb similarity index 85% rename from db/migrate/20150522164020_update_certs.rb rename to db/data/20150601083800_add_cert_md5.rb index 5cdaa7549..5efe4e596 100644 --- a/db/migrate/20150522164020_update_certs.rb +++ b/db/data/20150601083800_add_cert_md5.rb @@ -1,5 +1,5 @@ -class UpdateCerts < ActiveRecord::Migration - def change +class AddCertMd5 < ActiveRecord::Migration + def self.up Certificate.all.each do |x| if x.crt.present? && x.csr.present? x.interface = Certificate::REGISTRAR @@ -21,4 +21,8 @@ class UpdateCerts < ActiveRecord::Migration x.save end end + + def self.down + raise ActiveRecord::IrreversibleMigration + end end