How can I accomplish this in a schema?

I'm trying to make it so only one record with this itemId can have the status "ACTIVE" at a time. Something like this:

ALTER TABLE ItemMintPermission
ADD COLUMN ActiveItemID AS (CASE WHEN status='ACTIVE' THEN itemId ELSE NULL END) VIRTUAL;

ALTER TABLE ItemMintPermission
ADD UNIQUE INDEX idx_unique_active_item(ActiveItemID);
Was this page helpful?