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.
What was happening was that deleting an object of `ArticleVersion` was setting the `transaction_id` of the `TransactionChanges` object to NULL, which was causing a `AssertionError: Dependency rule tried to blank-out primary key column 'transaction_changes.transaction_id' on instance '<TransactionChanges at 0x7f7d17a544d0>'` error.

Deleting a version object should never affect a `TransactionChanges` object imo (at least not through foreign key behavior). If for instance you have 2 new `ArticleVersion`s, deleting one of them should not affect the existing TransactionChanges that points to the `ArticleVersion` (Deleting both of them should, but that's a different story).

With the above in mind, I don't think the `cascade='all, delete-orphan'` has a place here as it creates a wrong impression about what the motivation here is. The `passive_deletes=True` does make sense. I set it to `passive_deletes='all'` because according to documentation, if the changes object is in memory SQL Alchemy will **still** set the foreign key to NULL, which is not desired. This whole thing can also be avoided if we remove the `.changes` attribute on the version class; it can still be accessed through the `.transaction.changes` attribute chain.

What does make sense is to use `cascade='all, delete-orphan'` on the `Transaction->TransactionChanges` relation. When a whole transcation is deleted, the changes have to go away with it as well.