I am trying to add an index and a foreign key constraint to an existing table, each of which references a JSON expression.
The ADD INDEX command below is working by itself, but the statement fails when I add the ADD CONSTRAINT.
I'd appreciate any advice regarding what I'm doing wrong. Thanks.
ALTER TABLE MyTable
ADD INDEX 'MyTable_5' ( ( JSON_VALUE( MyTable, '$.someData' ) ) ),
ADD CONSTRAINT 'MyTable_5FK' FOREIGN KEY ( JSON_VALUE( MyTable, '$.someData' ) ) REFERENCES OtherTable (PK);