A set of stored procedures and functions encapsulating schema inspection via information_schema.
Get a list of databases that have field on any table with a given name.
select dbsWithField('product_id');
+-------------------------------------------------------------+
| dbsWithField('product_id') |
+-------------------------------------------------------------+
| trophies, customwear, pq_admin, curious, mysql, media_magic |
+-------------------------------------------------------------+
Get a list of talbes in a given database that have a field with a given name.
select tablesWithField('product_id', 'trophies');
+-------------------------------------------------------------+
| tablesWithField('product_id', 'trophies') |
+-------------------------------------------------------------+
| coupon_product, order_product, product, product_description |
+-------------------------------------------------------------+
Search for existence of a given field on a given table in a given database.
select fieldExists('product_id', 'coupon_product', 'trophies');
+--------------------------------------------------------+
| fieldExists('product_id', 'coupon_product', 'trohies') |
+--------------------------------------------------------+
| 1 |
+--------------------------------------------------------+
The stored procedures and functions need to go somewhere. You might like to create one just for them like inpsectors or something.
One thing you should note, the last parameter on fieldExists is optional. If installed on the database on which it is run, fieldExists will check the value of database(), in that case you can pass NULL for the value.
At any rate all you need to do is run the install.sql script on the database of your choice;
mysql -u admin -p -D inspectors < install.sql