Device id has to be set whenerver a user is logged in. It has to be removed when a user logs out/deletes accout.
With this approach a new id is generated when a new database gets created, or app launches and there is no id in the database.
This translates to these events:
- user logs out/deletes their account
- app starts/reloads and there is no id in the database for some reason
- SQLite database gets cleared in response to currentUserInfo.anonymous changing to true or currentUserInfo.id changing to a different value for other reasons
So the id is always present in the database, apart from very short periods of time after database creation.