-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Proposal
Part 1: timestamps
- We add two new columns
created_atandupdated_atto the table schema for tables:attributes(FKAattribute_definitions),resource_mappings,subject_mappings,attribute_values,key_access_servers. - We use
default NOW()in each table schema to set thecreated_atcolumn on creation. - We use a trigger to replace the
updated_attimestamp column in each table whenever a row is updated. - The
Metadataproto schema still includes both timestamps contained within, but the column value oftable[id].metadataJSON no longer includes the timestamps set by the services & their SQL queries since they are now individual columns on the row set at the DB level.
Part 2: description
- The Metadata proto schema no longer contains
descriptionas a separate field. (code example) - Docs/UXs (i.e. the in-flight CLI tool) direct users to place any description-like state within the metadata labels.
Background
We hold a JSONB selection of metadata in many of our tables within the refactored policy config schema. It stands to reason that we could split those off into a separate metadata table with a FK relationship from the table to its metadata, but that introduces the need for a new join on every single read of a table row, which has performance impact. This metadata exists to provide a mechanism for a platform administrator to store a set of labels for an attribute with internal meaning (hence the generic map[string]string label type) and to track creation and updation timestamps.
Simplicity and dynamicity are the goals. This proposal will move some SQL query logic into the schema so it's native Postgres and not the server assigning timestamps (which has plenty of benefits on its own), and it will simplify the proto Message schema so there is one less field to support and marshal/unmarshal in and out of JSON.
Scope: There is known desire for audit capabilities on config data accesses and changes, but those needs are not the immediate concern as they are likely far more contextual.
Scope: There is uncertainty around timestamps when there exists in a FQN the tree-like relationship from (pseudocode) namespace -> attribute[] -> attribute[each id].values[] -> optional value[id].members[]. We should track timestamps on each table's rows, but if an end user is looking for the last time an attribute was updated, does that really mean "an aspect of its values was changed" or "an attribute definition was changed" since an attribute has little meaning without an associated value? The answer to that question is out of scope, but is something to consider directionally with any decision.