Uh oh!
There was an error while loading. Please reload this page.
Add V140 migration: phoenix_kit_warehouse tables - #624
Merged
Conversation
Creates six tables for the standalone phoenix_kit_warehouse module: phoenix_kit_warehouse_stock, phoenix_kit_warehouse_inventory_documents, phoenix_kit_warehouse_internal_orders, phoenix_kit_warehouse_supplier_orders, phoenix_kit_warehouse_goods_receipts, phoenix_kit_warehouse_goods_issues. internal_orders and goods_issues carry a generic source_refs JSONB column instead of any FK to a host order table — the warehouse module resolves those refs through host-registered callbacks, so core stays agnostic of any particular order concept. Intra-module FKs preserved (supplier_orders -> internal_orders, goods_receipts -> supplier_orders, goods_issues -> internal_orders); performed_by_uuid FKs to phoenix_kit_users ON DELETE SET NULL on all five document tables. All DDL idempotent; sequences back per-document number columns.
ddon pushed a commit
that referenced
this pull request
Jul 9, 2026
Post-merge review of #624 (V140 warehouse tables). V140 was unpublished (hex latest == local 1.7.179), so the migration is amended in place rather than patched by a V141. - Fix: the quantity >= 0 CHECK guard matched pg_constraint.conname alone. Constraint names are unique per (schema, table), not globally, so a second install into another schema in the same database found the first schema's constraint and silently skipped ADD CONSTRAINT. Scoped with conrelid, as V41/V72/V78 already do. - Fix: source_refs shipped unindexed, so replacing the indexed sub_order_uuid FK with JSONB removed the index behind reverse lookups. Added GIN indexes on internal_orders, supplier_orders, goods_receipts, goods_issues. - Fix: phoenix_kit_warehouse_stock had no standalone location_uuid index; the composite UNIQUE (item_uuid, location_uuid) cannot serve WHERE location_uuid. - Update: V140 moduledoc justified four FK-less columns as "cross-package" references, but all four targets are created by this same core migration set and V122 already FKs location_uuid -> phoenix_kit_locations. Doc now states that an FK is possible, is omitted pending a delete-semantics decision, and that referential integrity for those columns is not enforced. Also removed a private downstream app's table names, which were rendering on hexdocs. The missing FKs are recorded in CLAUDE_REVIEW.md as BUG - MEDIUM rather than fixed: adding them requires choosing ON DELETE RESTRICT vs CASCADE, which is the warehouse package owner's decision. Also bumps ecto 3.14.1, postgrex 0.22.3, plug 1.20.3, mdex_native 0.2.5. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds versioned migration V140 creating the six tables that back the new standalone
phoenix_kit_warehousemodule (companion PR: BeamLabEU/phoenix_kit_warehouse#1):phoenix_kit_warehouse_stock— per item/location balance, unique(item_uuid, location_uuid), namedCHECK (quantity >= 0).phoenix_kit_warehouse_inventory_documents,_internal_orders,_supplier_orders,_goods_receipts,_goods_issues— sequence-numbered documents with draft/posted lifecycle columns, soft-delete columns,linesJSONB.Design notes:
internal_ordersandgoods_issuesdeliberately have no FK to any order table — the relationship lives in a genericsource_refsJSONB column resolved by host-registered callbacks in the warehouse module, keeping core agnostic of any host "order" concept.supplier_orders.internal_order_uuid→internal_orders,goods_receipts.supplier_order_uuid→supplier_orders,goods_issues.internal_order_uuid→internal_orders.performed_by_uuid→phoenix_kit_users(uuid) ON DELETE SET NULLon all five document tables.uuid_generate_v7()PKs,TIMESTAMPTZtimestamps, all DDL idempotent, prefix-aware — follows the V135+ file conventions exactly.@current_versionbumped 139 → 140; moduledoc changelog entry added with the ⚡ LATEST marker moved.Not included (maintainer-owned per repo conventions):
mix.exsversion bump and CHANGELOG entry — needed before the release that ships this.Verified: full local test suite boots clean through
PhoenixKit.Migration.ensure_current/2with V140 applied;mix compile --warnings-as-errorsclean; constraint/index shape verified against a live database (NOT NULL columns, 9 named constraints, 36 indexes).