stock_movements table
The stock_movements table in the Inventory Management Database Schema schema has 10 columns, keyed by id, with 2 foreign keys to products and locations.
The ledger. quantity is signed: positive adds, negative removes. reference_type and reference_id point back at the receipt, transfer or count that caused it.
Columns (10)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| product_id | uuid | not null, references products.id | |
| location_id | uuid | not null, references locations.id | |
| type | movement_type | not null | |
| quantity | integer | not null | |
| unit_cost_cents | integer | ||
| reference_type | varchar(40) | ||
| reference_id | uuid | ||
| performed_by | varchar(120) | ||
| occurred_at | timestamptz | not null |
Indexes (3)
(product_id, occurred_at)(location_id, occurred_at)(reference_type, reference_id)
Relationships
stock_movements.product_idreferencesproducts.idstock_movements.location_idreferenceslocations.id