Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Add phone to users table
Łukasz Adamczyk2aa5dcb98757
diff --git a/core/app/models/spree/address.rb b/core/app/models/spree/address.rbindex 300744cfa5..cc4651cf12 100644--- a/core/app/models/spree/address.rb+++ b/core/app/models/spree/address.rb@@ -225,7 +225,7 @@ module Spreedef set_default_valuesself.firstname ||= user.first_nameself.lastname ||= user.last_name- self.phone ||= user.phone if user.respond_to?(:phone)+ self.phone ||= user.phoneenddef clear_state@@ -260,6 +260,7 @@ module Spreeuser.first_name = firstnameuser.last_name = lastnameend+ user.phone = user.phone.presence || phone.presenceuser.save! if user.changed?enddiff --git a/core/db/migrate/20250127151258_add_phone_to_spree_users.rb b/core/db/migrate/20250127151258_add_phone_to_spree_users.rbnew file mode 100644index 0000000000..f11fe8c1c0--- /dev/null+++ b/core/db/migrate/20250127151258_add_phone_to_spree_users.rb@@ -0,0 +1,5 @@+class AddPhoneToSpreeUsers < ActiveRecord::Migration[6.1]+ def change+ add_column Spree.user_class.table_name, :phone, :string, if_not_exists: true+ end+enddiff --git a/core/lib/spree/testing_support/common_rake.rb b/core/lib/spree/testing_support/common_rake.rbindex c2b6a18686..01c14e7da0 100644--- a/core/lib/spree/testing_support/common_rake.rb+++ b/core/lib/spree/testing_support/common_rake.rb@@ -46,7 +46,7 @@ namespace :common dosystem('bin/rails db:environment:set RAILS_ENV=test > /dev/null 2>&1')system('bundle exec rake db:drop db:create > /dev/null 2>&1')Spree::DummyModelGenerator.start- system('bundle exec rake db:migrate > /dev/null 2>&1')+ system('bundle exec rake db:migrate')beginrequire "generators/#{ENV['LIB_NAME']}/install/install_generator"