Skip to content

feat: station_inventory_item migration replacing user_inventory_item #279

@GitAddRemote

Description

@GitAddRemote

User Story

As a developer, I need the station_inventory_item table created to replace the old user_inventory_item entity, so that inventory records are backed by the finalized schema with proper catalog and location references.

Background

The existing user_inventory_item entity is incompatible with the finalized schema. It references UexItem via integer uex_item_id, uses a polymorphic location_type/location_uex_id pair, and has no list support. It must be replaced entirely. See docs/schema/inventory-catalog-design.md.

Definition of Done

  • Migration creates station_inventory_item table
  • Migration drops or renames user_inventory_item table (with data migration plan if needed)
  • Old UserInventoryItem entity and related files removed or updated
  • UserInventoryModule and OrgInventoryModule updated to use new entity
  • All existing inventory API endpoints updated to read/write station_inventory_item
  • Unique constraint (owner_type, owner_id, catalog_entry_id, location_id) enforced
  • pnpm test passes
  • pnpm migration:revert tested

Schema

Column Type Nullable Default Notes
id UUID NO UUIDv7 PK
owner_type VARCHAR(10) NO user | org | alliance (future)
owner_id UUID NO Polymorphic FK to users or organizations
catalog_entry_id UUID NO FK → station_catalog_entry
location_id UUID NO FK → station_location
quantity NUMERIC(12,4) NO 1 Handles SCU fractions and whole unit counts
is_org_available BOOLEAN NO FALSE User-owned but flagged as available to org
notes TEXT YES NULL
created_at TIMESTAMPTZ NO now()
updated_at TIMESTAMPTZ NO now()

Unique constraint: (owner_type, owner_id, catalog_entry_id, location_id)

Depends on

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendBackend services and logicdatabaseSchema, migrations, indexingenhancementNew feature or requestinventoryInventory system featurestech-storyTechnical implementation story

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions