[wip] split email_users
this contains just the database schema for now, to discuss my proposal on how to split the table.
IAddress(for ingress/immerda address) is an address we accept mail for (open question: should lists also have an iaddress)
forwardroutes from 1
IAddressto 1 "to" address which can be any internal/external address, represented as string (for uniformity)
account(email_user) has 1
is just a concept, namely ais a forward where the to is an email_user. These will also be user managed resources. They can be shared, ie. multiple aliases can have the same iaddress.
forwardwhere the "to" field happens to contain the string of the iaddress of an account
cleanup I envision as follows:
- deleting any record that holds the last reference to an iaddress transfers it to a deleted_email entry for that iaddress.
- if the deleted_email expires, the associated iaddress is deleted too.
There is the danger that we create dangling iaddresses. The reason is that creating a new resource is now two step: 1. create iaddress, 2. create resource. This could fail intermittently. To fix this probably the easiest is a regular cleanup job, that deletes unused iaddresses. This can be done by checking twice with a couple seconds delay, to allow transactions in flight to complete.
this schema gives us the full flexibility and therefore allows us to fully migrate what we have now. the downside is that it allows us to create circles and chains. a circle is a chain of forwards that diverges. a chain is a forward, where the "to" address is a forward. we should have a validation that forbids circles. should we also forbid chains? currently we have many of them. they are kinda useful as they allow tree-shaped maillists, where children are sub-lists.