Version the completion database and wipe it out automatically if the version changes. Add unique constaint to scopes, and use REPLACE rather than INSERT, fixing leaking prepared statements