Versioning issues on session.flush

Hey, opening a pull request with some fixes related to mid-transaction flushes. Check the added tests to see what I think the expected behavior should be
- Keep the version's type as INSERT when a new object is flushed and then modified within the same single transaction. Currently there is no insert entry ever created.
- Ensure the same versioning behavior when primary keys of objects are modified after a flush, with the behavior that you get when they are modified without a flush.

Update:
- When a new object is created, flushed, then deleted (all in the same transaction), no version entry to be saved.
- Postgres triggers have also been updated.
This is needed otherwise after deleting a version sql alchemy will by default set the transaction_id of the TransactionChange to NULL, which is never desired.