The default not null constraint only checks for the SQL null, not a json
null.
Therefore add an extended not null constraint by checking both possible
null values.
This also adds a view to get a list of all containers and their free
space in between.
This is needed for ippool_list to get a nice overview over everything.
The code of the function is based on
https://pkg.go.dev/inet.af/netaddr#IPRange.Prefixes
Many thanks to Brad Fitzpatrick for the awesome code and changelog to
make it possible to understand what is going on.
This commit consists of two things.
1. server.go will now set two variables for the current transaction, the
username and request id. These are transaction local and therefore do
not leak into the connection.
2. The initial schema received a history table and a trigger. This
trigger writes changes into the history table. When inserting records
the function will pull the transaction local variables and add them
to the record.
The trigger is added to all tables, so that a complete changelog is
created.
These changes serve as the basis for further features. One is the
searching for changes on specific resources (think history rr, history
zone, ...).
The other feature is a way to subscribe to changes in the database based
on filters. This will be the way to implement the output feature of dim.
Containers are subnets in vairous ranges. But only when a subnet is
assigned a pool, it is truly a subnet. When it is not assigned to a
pool, it is considered a container.
This serves the purpose of grouping or blocking containers for different
purposes, so we need to keep that up.