How to get issues that were added or removed from a Program Increment (PI)

I am using Jira Rest API to get list of issues given a JQL query, the current query is: project in (‘KEY1’, ‘KEY2’) AND “Program Increment” = PI3. This works fine, and it also works on the normal search UI in Jira. Note that Program Increment comes from Easy Agile Programs app. The issue happens when I change the query to have was instead of = . From the Jira UI, I get this error: “History searches do not support the ‘Program Increment’ field.” Which is pretty self explanatory.

My question: is there a way to achieve what I want by performing a history search based on the Program Increment? If not, then my other alternative is in the beginning of every PI, get the list and store it in a database, then every time I want to see what was added or removed, get the current issues using the API, and compare the list in the database with the new list. This is very not ideal, as it will require me to have a database instance running somewhere at all times. Other suggestions?