The previous implementation of the sync untracked feature would attempt
to run multiple queries in parallel. The `knex` framework appears to use
a separate connection for each query by default (unless the queries are
tied together by a transaction). When using sqlite, there is only a
single connection available in the knex database pool, causing this
feature to deadlock (when the initial query can not return all results
immediatly).
In this change, we switch to doing all of these queries in a
transaction, which causes all quries to occur on a single connection.