I'm trying to figure out how to create an index on the KEY (UUID) in the following JSONB structure using alembic. I only really want to index the key as there are many fields..
I'm not sure how this is supposed to work as the field does not have a static name I can feed into table_args?
json_data = {
'UUID': {
'field1': 'v1',
'field2': 'v2',
},
'UUID': {
'field1': 'v1',
'field2': 'v2',
}
}
class TestThing(db.Model):
__tablename__ = 'test_thing'
__table_args__ = (db.Index('ix_1', TestThing.json_data['UUID']))
id = db.Column(db.BigInteger(), primary_key=True)
json_data = db.Column(JSONB)