flush the changes to the database