Skip to content

M3 Database Schema

The M3 database stores inventory items, locations, stock movements, and alerting. It is a PostgreSQL schema generated from Prisma migrations.

TablePurposeNotes
propertiesInventory properties (villas)Top-level grouping
locationsHierarchical storage locationsSupports parent-child locations
zonesGrouping of locationsOptional grouping layer
item_categoriesCategory tree for inventory itemsSelf-referencing parent-child
inventory_itemsCore inventory item recordsLinks to property, location, category
item_photosItem photo metadataLinked to inventory_items
stock_movementsAudit trail of stock changesLinked to inventory_items
linen_typesLinen type definitionsUsed by linen tracking
linen_inventoryLinen item trackingLinked to items and types
inventory_alertsLow stock and condition alertsLinked to items and properties
inventory_snapshotsPeriodic stock snapshotsLinked to properties
consumable_typesConsumable item typesUsed by consumables tracking
consumable_itemsConsumable item recordsLinked to types and properties
item_templatesTemplate definitionsFor bulk item creation
template_itemsItems within a templateLinked to item_templates
audit_logSystem audit trailRecords changes and actions
  • locations.propertyIdproperties.id
  • locations.parentIdlocations.id
  • zones.locationIdlocations.id
  • item_categories.parentIditem_categories.id
  • inventory_items.propertyIdproperties.id
  • inventory_items.locationIdlocations.id
  • inventory_items.zoneIdzones.id
  • inventory_items.categoryIditem_categories.id
  • item_photos.itemIdinventory_items.id
  • stock_movements.itemIdinventory_items.id
  • stock_movements.fromLocationIdlocations.id
  • stock_movements.toLocationIdlocations.id
  • linen_inventory.itemIdinventory_items.id
  • linen_inventory.linenTypeIdlinen_types.id
  • inventory_alerts.itemIdinventory_items.id
  • inventory_alerts.propertyIdproperties.id
  • inventory_snapshots.propertyIdproperties.id
  • consumable_items.propertyIdproperties.id
  • consumable_items.consumableTypeIdconsumable_types.id
  • template_items.templateIditem_templates.id
EnumValues
ItemCategoryequipment, consumable, linen, operational, decor, safety, signage, kitchenware, tableware, bathroom, bedroom, outdoor, electronics, furniture
ItemConditionnew, excellent, good, fair, needs_repair, needs_replacement
LocationTypebuilding, floor, room, area, zone_group, other
StockMovementTypeinitial, purchase, return_item, use, damage, loss, transfer_in, transfer_out, adjustment
AlertStatusactive, acknowledged, resolved
  • inventory_items is the central table; most inventory data links to it directly.
  • Location hierarchy uses a self-referencing locations.parentId for nesting.

Schema extracted from D:\Development\m2-main\db_export\m3.sql.