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
Phase P1.1: Add typed stock movement columns
Łukasz Adamczyk44879f29dc2a
diff --git a/spree/core/db/migrate/20260814000002_add_typed_stock_movements.rb b/spree/core/db/migrate/20260814000002_add_typed_stock_movements.rbnew file mode 100644index 0000000000..d642f8618d--- /dev/null+++ b/spree/core/db/migrate/20260814000002_add_typed_stock_movements.rb@@ -0,0 +1,25 @@+class AddTypedStockMovements < ActiveRecord::Migration[8.1]+ # Typed stock movements (docs/plans/6.0-typed-stock-movements.md): a `kind`+ # says what happened to stock and concrete foreign keys say why, replacing+ # the polymorphic originator. `allocated_count` carries the units promised+ # to placed orders, so `count_on_hand` can go back to meaning what a picker+ # can count.+ #+ # `kind` stays nullable until the data task has had a release to type the+ # history; the model requires it, so every row 6.0 writes is typed.+ def change+ change_table :spree_stock_movements, bulk: true do |t|+ t.string :kind+ t.string :reason+ t.references :order+ t.references :fulfillment+ t.references :return+ t.references :exchange+ t.references :stock_transfer+ end++ add_index :spree_stock_movements, :kind++ add_column :spree_stock_levels, :allocated_count, :integer, null: false, default: 0+ end+end