[db] Started overhauling the database API

Actually changing the API, breaking backwards compatibility.