Write out database thread
Write out local IDs of models