So I ran into a lovely issue while porting MiqGroup#filters (text blob, serialized hash) to Entitlement filter columns (Postgres Array columns, divided): Postgres multidimensional arrays must be of equal length.
The problem with this is that we currently store filters like this:
[["/managed/environment/dev"],
["/managed/location/chicago", "/managed/location/london"],
["/managed/prov_max_cpu/1"],
["/managed/service_level/gold"]]
I was originally going to leave the format as is because it affects too much to change it.
But now I realize I can't do that (at least, not without just porting over a serialized text blob).
The current format is pretty fragile, plus with multiple columns now the prefixes (i.e. /managed/
) are pointless.
Maybe we should port this to a JSON column, an excellent tool for 'tagging'. Then...
{ "environment": ["dev"],
"location": ["chicago", "london"],
"service_level": ["gold"] }
Problems:
- These are just filters, not the actual tags themselves...so I'm guessing tags elsewhere will have to be changed. That could be a very, very large undertaking.
- My example is just for
tag_filters
("managed" filters); I can't really deduce what the format is for 'belongsto' yet. I'm guessing it could work similarly.
Ultimately, we must do tagging in a better way now IMO, as the next step is for ✨ Multiple entitlements ✨ which need to be able to make sense of 'merging' filters. (Right?)
Tags are assigned via the Taggings table, so they are relatively simple. It might make sense to just leverage that directly and not worry about the Array column. My other thought on reading this is that I think this
can just be stored like this
or even without those intermediate arrays?