-
/api/drivers- GET, POST updated -
/api/drivers/[id]- GET, PATCH updated -
/api/markets- GET, POST updated -
/api/templates- GET, POST, DELETE updated
The following routes contain complex SQLite-specific queries that need manual async conversion:
Lines to update:
- Line 22:
getShiftTemplates(market)→await getShiftTemplates(market) - Line 31:
getScheduledShifts({ market, date })→await getScheduledShifts({ market, date }) - Line 44:
getCapacityForDate(template.id, date)→await getCapacityForDate(template.id, date) - Line 83:
getScheduleSettings()→await getScheduleSettings() - Line 84:
getDriverById(driverId)→await getDriverById(driverId) - Line 95-101: Replace
db.prepare().get()withawait db.execute()and array destructuring - Line 121:
getCapacityForDate(templateId, date)→await getCapacityForDate(templateId, date) - Line 122-125: Replace
db.prepare().get()withawait db.execute() - Line 138:
getScheduledShifts({ driverId, date: prevDate })→await getScheduledShifts(...) - Line 164:
getScheduledShifts({ driverId, date })→await getScheduledShifts(...) - Line 197:
getScheduledShifts({ driverId, date: nextDate })→await getScheduledShifts(...) - Line 211-214: Replace
db.prepare().run()withawait db.execute() - Line 220:
result.lastInsertRowid→result.insertId - Line 231:
SQLITE_CONSTRAINT_UNIQUE→ER_DUP_ENTRY
Lines to update:
- Line 7:
getScheduleSettings()→await getScheduleSettings() - Line 45:
updateScheduleSettings(...)→await updateScheduleSettings(...) - Line 52:
getScheduleSettings()→await getScheduleSettings()
/api/shifts/[id]/route.ts- DELETE handler/api/templates/[id]/route.ts- PATCH handler/api/markets/[id]/route.ts- PATCH handler/api/capacity-overrides/route.ts- GET, POST handlers/api/schedules/route.ts- GET, POST handlers/api/slack/post-schedule/route.ts- POST handler
// OLD (SQLite)
const result = db.prepare('SELECT * FROM table WHERE id = ?').get(id);
// NEW (MySQL)
const [rows] = await db.execute('SELECT * FROM `table` WHERE id = ?', [id]);
const result = (rows as any[])[0];// OLD (SQLite)
const result = db.prepare('INSERT INTO table (col) VALUES (?)').run(value);
const id = result.lastInsertRowid;
// NEW (MySQL)
const [result] = await db.execute('INSERT INTO `table` (col) VALUES (?)', [value]) as any;
const id = result.insertId;// OLD (SQLite)
const result = db.prepare('DELETE FROM table WHERE id = ?').run(id);
if (result.changes === 0) { /* not found */ }
// NEW (MySQL)
const [result] = await db.execute('DELETE FROM `table` WHERE id = ?', [id]) as any;
if (result.affectedRows === 0) { /* not found */ }After updates:
- Start dev server:
npm run dev - Test driver CRUD operations
- Test market management
- Test shift template creation/deletion
- Test shift claiming/canceling
- Test settings updates
- Verify error handling (duplicates, foreign keys)