Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Declared the settlement columns required on the column itself

Łukasz Adamczykada06e3422fb
diff --git a/spree/core/db/migrate/20260914000001_add_settlement_to_spree_seller_transfers.rb b/spree/core/db/migrate/20260914000001_add_settlement_to_spree_seller_transfers.rb
index 87cfa675b4..1770cf446e 100644
--- a/spree/core/db/migrate/20260914000001_add_settlement_to_spree_seller_transfers.rb
+++ b/spree/core/db/migrate/20260914000001_add_settlement_to_spree_seller_transfers.rb
@@ -4,32 +4,13 @@
# This records a conversion the provider performed and reported. Spree still
# holds no exchange rates and converts nothing itself.
#
-# The columns are NOT NULL, because every query that groups or sums by
-# settlement reads them directly — a null row would fall out of balances and
-# out of payout selection without saying so. A row starts out settling in the
-# currency it was sold in, which is the truth outright for a provider that
-# converts nothing, and a provider that does converts overwrites both.
-#
-# The columns are seeded here rather than by a rake task: they are introduced
-# by this migration, in a release that has not shipped, so this is a new
-# column's initial value rather than a transformation of data anyone holds.
+# Required rather than nullable: every query that groups or sums by settlement
+# reads these columns directly, so a null row would fall out of balances and
+# out of payout selection without saying so.
class AddSettlementToSpreeSellerTransfers < ActiveRecord::Migration[8.1]
def change
- add_column :spree_seller_transfers, :settled_amount, :decimal, precision: 10, scale: 2
- add_column :spree_seller_transfers, :settled_currency, :string
-
- reversible do |direction|
- direction.up do
- execute(<<~SQL.squish)
- UPDATE spree_seller_transfers
- SET settled_amount = amount, settled_currency = currency
- WHERE settled_amount IS NULL OR settled_currency IS NULL
- SQL
- end
- end
-
- change_column_null :spree_seller_transfers, :settled_amount, false
- change_column_null :spree_seller_transfers, :settled_currency, false
+ add_column :spree_seller_transfers, :settled_amount, :decimal, precision: 10, scale: 2, null: false
+ add_column :spree_seller_transfers, :settled_currency, :string, null: false
add_index :spree_seller_transfers, [:seller_id, :settled_currency, :status],
name: 'index_seller_transfers_on_seller_and_settled_currency'