Skip to content

Commit

Permalink
Add migration and disable validation is person model
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelMoeri committed Jun 17, 2024
1 parent e1f53d4 commit 0cde899
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 0cde899

Please sign in to comment.