From 0cde8994af4795476beb9482e8ab357e0a3962d2 Mon Sep 17 00:00:00 2001 From: Manuel Date: Mon, 17 Jun 2024 10:50:58 +0200 Subject: [PATCH] Add migration and disable validation is person model --- app/models/person.rb | 6 +++--- ...240617064850_change_nationality2_to_json_in_people.rb | 9 +++++++++ db/schema.rb | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20240617064850_change_nationality2_to_json_in_people.rb diff --git a/app/models/person.rb b/app/models/person.rb index e5e852424..2657b7442 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -59,9 +59,9 @@ class Person < ApplicationRecord validates :nationality, inclusion: { in: ISO3166::Country.all.collect(&:alpha2) } - validates :nationality2, - inclusion: { in: ISO3166::Country.all.collect(&:alpha2) }, - allow_blank: true + # validates :nationality2, + # inclusion: { in: ISO3166::Country.all.collect(&:alpha2) }, + # allow_blank: true validate :picture_size diff --git a/db/migrate/20240617064850_change_nationality2_to_json_in_people.rb b/db/migrate/20240617064850_change_nationality2_to_json_in_people.rb new file mode 100644 index 000000000..d381e2242 --- /dev/null +++ b/db/migrate/20240617064850_change_nationality2_to_json_in_people.rb @@ -0,0 +1,9 @@ +class ChangeNationality2ToJsonInPeople < ActiveRecord::Migration[7.0] + def up + change_column :people, :nationality2, :json, using: %q{to_json(regexp_split_to_array(nationality2, E'\\\\s+'))} + end + + def down + delete_column :people, :nationality2 + end +end diff --git a/db/schema.rb b/db/schema.rb index 14cf33abf..d133bc148 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_06_03_085509) do +ActiveRecord::Schema[7.0].define(version: 2024_06_17_064850) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -143,7 +143,7 @@ t.bigint "company_id" t.datetime "associations_updatet_at", precision: nil t.string "nationality" - t.string "nationality2" + t.json "nationality2" t.integer "marital_status", default: 0, null: false t.string "email" t.integer "department_id"