feat(database):correct trigger generation (fixes #4461)