V140: Warehouse module tables.
Creates the six phoenix_kit_warehouse_* tables that back the standalone
phoenix_kit_warehouse package: stock, inventory_documents,
internal_orders, supplier_orders, goods_receipts, goods_issues.
These mirror the shape of the host-application tables the module was extracted from, minus every FK that pointed at a host-specific table:
internal_ordersandgoods_issuesdrop thesub_order_uuidFK — that relationship now lives exclusively in the genericsource_refsJSONB column ([%{"kind" => "sub_order", "uuid" => ...}, ...]), resolved by a host-registered callback rather than a hard FK to an order table this package doesn't own. A GIN index onsource_refsstands in for the index the dropped FK column used to provide, so the reverse lookup ("which documents reference this order?") stays off a sequential scan.- Intra-module FKs are kept:
supplier_orders.internal_order_uuid→internal_orders,goods_receipts.supplier_order_uuid→supplier_orders,goods_issues.internal_order_uuid→internal_orders. performed_by_uuidstays FK'd tophoenix_kit_userson every document table (core-to-core reference, unchanged from the originals).item_uuid,location_uuid,storage_folder_uuid, andsupplier_uuidare plain UUID columns. Their targets (phoenix_kit_cat_items,phoenix_kit_locations,phoenix_kit_media_folders,phoenix_kit_cat_suppliers) are all created by this same core migration set, so an FK would be physically possible. It is omitted because the delete semantics — restrict a location that still holds stock, versus cascade the documents away with it — are a product decision the warehouse package has not made yet. Until it does, referential integrity for these four columns is not enforced by the database, and a danglinglocation_uuidwill not be rejected on insert.
This migration ships the tables only — no application code reads or writes them yet, and no data is copied from the host's legacy tables (that is a separate, later host-side data migration, run only after the new package and its LiveViews are built and verified).
Summary
Functions
Drops all six warehouse tables and their sequences, in FK-safe order (dependents before the tables they reference). Destroys any data written to them — safe only because, per this plan, nothing writes to them yet.