@@ -8,31 +8,31 @@ TRUNCATE TABLE items;
TRUNCATE TABLE users ;
TRUNCATE TABLE users ;
SET FOREIGN_KEY_CHECKS = 1 ;
SET FOREIGN_KEY_CHECKS = 1 ;
-- Users (roles 1– 6, plain-text passwords)
-- Users (roles 1– 6, plain-text passwords; is_admin is BOOL )
INSERT INTO users ( username , password , email , first_name , last_name , role , is_admin ) VALUES
INSERT INTO users ( username , password , email , first_name , last_name , role , is_admin ) VALUES
( ' admin ' , ' adminpass ' , ' admin@example.com ' , ' System ' , ' Admin ' , 6 , true ) ,
( ' admin ' , ' adminpass ' , ' admin@example.com ' , ' System ' , ' Admin ' , 6 , TRUE ) ,
( ' alice ' , ' alice123 ' , ' alice@example.com ' , ' Alice ' , ' Andersen ' , 1 , false ) ,
( ' alice ' , ' alice123 ' , ' alice@example.com ' , ' Alice ' , ' Andersen ' , 1 , FALSE ) ,
( ' bob ' , ' bob12345 ' , ' bob@example.com ' , ' Bob ' , ' Berg ' , 2 , false ) ,
( ' bob ' , ' bob12345 ' , ' bob@example.com ' , ' Bob ' , ' Berg ' , 2 , FALSE ) ,
( ' carol ' , ' carol123 ' , ' carol@example.com ' , ' Carol ' , ' Christensen ' , 3 , false ) ,
( ' carol ' , ' carol123 ' , ' carol@example.com ' , ' Carol ' , ' Christensen ' , 3 , FALSE ) ,
( ' dave ' , ' dave123 ' , ' dave@example.com ' , ' Dave ' , ' Dahl ' , 4 , false ) ,
( ' dave ' , ' dave123 ' , ' dave@example.com ' , ' Dave ' , ' Dahl ' , 4 , FALSE ) ,
( ' erin ' , ' erin123 ' , ' erin@example.com ' , ' Erin ' , ' Enevoldsen ' , 5 , false ) ,
( ' erin ' , ' erin123 ' , ' erin@example.com ' , ' Erin ' , ' Enevoldsen ' , 5 , FALSE ) ,
( ' frank ' , ' frank123 ' , ' frank@example.com ' , ' Frank ' , ' Fisher ' , 2 , false ) ,
( ' frank ' , ' frank123 ' , ' frank@example.com ' , ' Frank ' , ' Fisher ' , 2 , FALSE ) ,
( ' grace ' , ' grace123 ' , ' grace@example.com ' , ' Grace ' , ' Gundersen ' , 1 , false ) ,
( ' grace ' , ' grace123 ' , ' grace@example.com ' , ' Grace ' , ' Gundersen ' , 1 , FALSE ) ,
( ' heidi ' , ' heidi123 ' , ' heidi@example.com ' , ' Heidi ' , ' Hansen ' , 4 , false ) ,
( ' heidi ' , ' heidi123 ' , ' heidi@example.com ' , ' Heidi ' , ' Hansen ' , 4 , FALSE ) ,
( ' tech ' , ' techpass ' , ' tech@example.com ' , ' Tech ' , ' User ' , 5 , true ) ;
( ' tech ' , ' techpass ' , ' tech@example.com ' , ' Tech ' , ' User ' , 5 , TRUE ) ;
-- Items (safe_nr is two digits or NULL; currently_borrowing aligns with active loans )
-- Items (safe_nr is two digits or NULL; matches CHECK and UNIQUE constraint )
INSERT INTO items ( item_name , can_borrow_role , in_safe , safe_nr , last_borrowed_person , currently_borrowing ) VALUES
INSERT INTO items ( item_name , can_borrow_role , in_safe , safe_nr , last_borrowed_person , currently_borrowing ) VALUES
( ' Laptop A ' , 2 , false , NULL , ' grace ' , ' bob ' ) ,
( ' Laptop A ' , 2 , FALSE , NULL , ' grace ' , ' bob ' ) ,
( ' Laptop B ' , 2 , true , ' 01 ' , NULL , NULL ) ,
( ' Laptop B ' , 2 , TRUE , ' 01 ' , NULL , NULL ) ,
( ' Camera Canon ' , 3 , true , ' 02 ' , ' erin ' , NULL ) ,
( ' Camera Canon ' , 3 , TRUE , ' 02 ' , ' erin ' , NULL ) ,
( ' Microphone Rode ' , 1 , true , ' 03 ' , ' grace ' , NULL ) ,
( ' Microphone Rode ' , 1 , TRUE , ' 03 ' , ' grace ' , NULL ) ,
( ' Tripod Manfrotto ' , 1 , true , ' 04 ' , ' frank ' , NULL ) ,
( ' Tripod Manfrotto ' , 1 , TRUE , ' 04 ' , ' frank ' , NULL ) ,
( ' Oscilloscope Tek ' , 4 , true , ' 05 ' , NULL , NULL ) ,
( ' Oscilloscope Tek ' , 4 , TRUE , ' 05 ' , NULL , NULL ) ,
( ' VR Headset ' , 3 , false , NULL , ' heidi ' , ' carol ' ) ,
( ' VR Headset ' , 3 , FALSE , NULL , ' heidi ' , ' carol ' ) ,
( ' Keycard Programmer ' , 6 , true , ' 06 ' , ' admin ' , NULL ) ;
( ' Keycard Programmer ' , 6 , TRUE , ' 06 ' , ' admin ' , NULL ) ;
-- Loans (JSON array s, 6-digit numeric loan_code)
-- Loans (JSON string s, 6-digit numeric loan_code per CHECK )
-- Assumes the items above have ids 1..8 in insert order
-- Assumes the items above have ids 1..8 in insert order
INSERT INTO loans (
INSERT INTO loans (
username ,
username ,
@@ -47,7 +47,7 @@ INSERT INTO loans (
deleted ,
deleted ,
note
note
) VALUES
) VALUES
-- Active loan: bob has Laptop A
-- Active loan: bob has Laptop A (item id 1, locker "01")
( ' bob ' ,
( ' bob ' ,
' ["01"] ' ,
' ["01"] ' ,
' 123456 ' ,
' 123456 ' ,
@@ -57,10 +57,10 @@ INSERT INTO loans (
NULL ,
NULL ,
' [1] ' ,
' [1] ' ,
' ["Laptop A"] ' ,
' ["Laptop A"] ' ,
false ,
FALSE ,
' Active loan - Laptop A '
' Active loan - Laptop A '
) ,
) ,
-- Returned loan: frank had Tripod Manfrotto
-- Returned loan: frank had Tripod Manfrotto (item id 5, locker "04")
( ' frank ' ,
( ' frank ' ,
' ["04"] ' ,
' ["04"] ' ,
' 234567 ' ,
' 234567 ' ,
@@ -70,10 +70,10 @@ INSERT INTO loans (
' 2025-10-05 15:30:00 ' ,
' 2025-10-05 15:30:00 ' ,
' [5] ' ,
' [5] ' ,
' ["Tripod Manfrotto"] ' ,
' ["Tripod Manfrotto"] ' ,
false ,
FALSE ,
' Completed loan '
' Completed loan '
) ,
) ,
-- Future reservation: dave will take Oscilloscope Tek
-- Future reservation: dave will take Oscilloscope Tek (item id 6, locker "05")
( ' dave ' ,
( ' dave ' ,
' ["05"] ' ,
' ["05"] ' ,
' 345678 ' ,
' 345678 ' ,
@@ -83,10 +83,10 @@ INSERT INTO loans (
NULL ,
NULL ,
' [6] ' ,
' [6] ' ,
' ["Oscilloscope Tek"] ' ,
' ["Oscilloscope Tek"] ' ,
false ,
FALSE ,
' Reserved '
' Reserved '
) ,
) ,
-- Active loan: carol has VR Headset
-- Active loan: carol has VR Headset (item id 7, locker "02")
( ' carol ' ,
( ' carol ' ,
' ["02"] ' ,
' ["02"] ' ,
' 456789 ' ,
' 456789 ' ,
@@ -96,10 +96,10 @@ INSERT INTO loans (
NULL ,
NULL ,
' [7] ' ,
' [7] ' ,
' ["VR Headset"] ' ,
' ["VR Headset"] ' ,
false ,
FALSE ,
' Active loan - VR Headset '
' Active loan - VR Headset '
) ,
) ,
-- Soft-deleted historic loan: grace had Microphone + Tripod
-- Soft-deleted historic loan: grace had Microphone + Tripod (item ids 4,5; lockers "03","04")
( ' grace ' ,
( ' grace ' ,
' ["03","04"] ' ,
' ["03","04"] ' ,
' 567890 ' ,
' 567890 ' ,
@@ -109,11 +109,11 @@ INSERT INTO loans (
' 2025-09-03 16:45:00 ' ,
' 2025-09-03 16:45:00 ' ,
' [4,5] ' ,
' [4,5] ' ,
' ["Microphone Rode","Tripod Manfrotto"] ' ,
' ["Microphone Rode","Tripod Manfrotto"] ' ,
true ,
TRUE ,
' Canceled/soft-deleted record '
' Canceled/soft-deleted record '
) ;
) ;
-- API keys (8-digit numeric keys)
-- API keys (8-digit numeric keys per CHECK )
INSERT INTO apiKeys ( api_key , entry_name , last_used_at ) VALUES
INSERT INTO apiKeys ( api_key , entry_name , last_used_at ) VALUES
( ' 12345678 ' , ' CI token ' , ' 2025-11-15 08:00:00 ' ) ,
( ' 12345678 ' , ' CI token ' , ' 2025-11-15 08:00:00 ' ) ,
( ' 87654321 ' , ' Local dev ' , NULL ) ,
( ' 87654321 ' , ' Local dev ' , NULL ) ,