From c97d6021e009a4639f3cc697cb4f514d3f8ae3cc Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Thu, 11 May 2023 17:35:19 +0530 Subject: [PATCH] chore: Add migration to set the default empty string value for contact name (#7052) Fixes: https://linear.app/chatwoot/issue/CW-1650/issue-with-the-contact-name --- app/models/contact.rb | 2 +- ...230510113208_set_default_empty_string_for_contact_name.rb | 5 +++++ db/schema.rb | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20230510113208_set_default_empty_string_for_contact_name.rb diff --git a/app/models/contact.rb b/app/models/contact.rb index 4f7832ac8..934fbd387 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -8,7 +8,7 @@ # email :string # identifier :string # last_activity_at :datetime -# name :string +# name :string default("") # phone_number :string # created_at :datetime not null # updated_at :datetime not null diff --git a/db/migrate/20230510113208_set_default_empty_string_for_contact_name.rb b/db/migrate/20230510113208_set_default_empty_string_for_contact_name.rb new file mode 100644 index 000000000..ae28c4318 --- /dev/null +++ b/db/migrate/20230510113208_set_default_empty_string_for_contact_name.rb @@ -0,0 +1,5 @@ +class SetDefaultEmptyStringForContactName < ActiveRecord::Migration[7.0] + def change + change_column_default :contacts, :name, from: nil, to: '' + end +end diff --git a/db/schema.rb b/db/schema.rb index d76da249a..459e97320 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: 2023_05_10_060828) do +ActiveRecord::Schema[7.0].define(version: 2023_05_10_113208) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "pg_trgm" @@ -394,7 +394,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_10_060828) do end create_table "contacts", id: :serial, force: :cascade do |t| - t.string "name" + t.string "name", default: "" t.string "email" t.string "phone_number" t.integer "account_id", null: false