One time database update process as part of applying a patch I have a PostgreSQL database that requires a server side script to be executed (client prefers php) to:


Perform some intelligent data modifications to records that will be
identified  only during the update. 
Update specific functions for a
dynamically identified list of schemas. 
Generate a static rollback
script/data based upon what is being modified.


I am hoping to integrate it with gitflow like process to allow for some control and visibility as in the past these types of changes were done manually.  I've been looking for something similar to libraries like phpunit to avoid reinventing.

Are there any scripting libraries or tools that can serve as a starting point.
This is usually called a migration, try yii2, Laravel or doctrine

Mostly these frameworks will manage the schema in yml, XML or PHP and automatically calculate schema changes and apply them.

For data changes, you would package up a number of database queries or even program code into a migration, which usually has a forward/up step and a backward/down step.

Migration status is usually stored as a single value in a separate database table