fetchNextTask static method
Returns a query that fetches the highest-priority pending task using FIFO ordering when priorities match.
Implementation
static String fetchNextTask(String tableName) {
return '''
SELECT * FROM $tableName
WHERE state = 'pending'
ORDER BY priority DESC, created_at ASC
LIMIT 1
''';
}