When losing connection to the database before .delete_orphans() is called when deleting a run, the database may end up in a state causing ixmp4 to not call delete_orphans again and sqlalchemy trying to remedy left over ts records by updating run__id to NULL (which results in a NOT NULL violation).