From 2e4bf0ee6e35d3d2c04af57c8f2fc9b66f4e9f80 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Mon, 4 May 2015 14:15:09 +0300 Subject: [PATCH] Update legacy registrar codes just in case --- .../20150504110926_validate_registrar_codes.rb | 12 ++++++++++++ db/schema.rb | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20150504110926_validate_registrar_codes.rb diff --git a/db/migrate/20150504110926_validate_registrar_codes.rb b/db/migrate/20150504110926_validate_registrar_codes.rb new file mode 100644 index 000000000..d8339a506 --- /dev/null +++ b/db/migrate/20150504110926_validate_registrar_codes.rb @@ -0,0 +1,12 @@ +class ValidateRegistrarCodes < ActiveRecord::Migration + def change + Registrar.all.each do |registrar| + if registrar.code.present? + registrar.update_column(:code, registrar.code.gsub(/[ :]/, '').upcase) + else + puts "NB! FOUND REGISTRAR WITHOUT CODE (HANDLER): #{registrar.id}; #{registrar.name}" + puts "Please add registrar code manually in database!" + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index e2afbfa2d..5285ccc6c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150504104922) do +ActiveRecord::Schema.define(version: 20150504110926) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql"