update trigger for postgresql compat.  Should this be in db.py anyway??