Improve migrations using triggers
This improves our migration helpers code so triggers are only created if possible, and dropping them happens only if necessary.
See https://gitlab.com/gitlab-org/gitlab-ce/issues/36633 and the commits in this MR for more information.
General Checklist
-
Changelog entry added, if necessary -
Tests added for this feature/bug - Review
-
Has been reviewed by Backend -
Has been reviewed by Database
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Squashed related commits together