Currently, the primary key of the item table is itemID, which is an auto-incremented value.
All of the item endpoints, however, use barcode for interacting with items. itemID is only really used by rentals, and even there, it gets in the way. It would be simpler to address items solely by their barcode.
The original concern with using barcode as a primary key was that it can change, but using ON UPDATE CASCADE in the database should fix that problem.
This change should allow for the removal of some joins in the rental and item endpoints.
Database
[x] Change rental.itemID to rental.barcode
[x] Change join in itemDetails view to use item.barcode
[x] Remove item.itemID and change primary key to item.barcode + item.organizationID
API
[x] Remove item.withRentals
[x] Update docs for "get item rentals"
[x] Update docs for all rental endpoints
[x] Remove rental.withBarcode and modify rental.withBarcodeAndPagination
Currently, the primary key of the item table is
itemID
, which is an auto-incremented value.All of the item endpoints, however, use
barcode
for interacting with items.itemID
is only really used by rentals, and even there, it gets in the way. It would be simpler to address items solely by their barcode.The original concern with using barcode as a primary key was that it can change, but using
ON UPDATE CASCADE
in the database should fix that problem.This change should allow for the removal of some joins in the rental and item endpoints.
Database
rental.itemID
torental.barcode
itemDetails
view to useitem.barcode
item.itemID
and change primary key toitem.barcode
+item.organizationID
API
item.withRentals
rental.withBarcode
and modifyrental.withBarcodeAndPagination