Automated scan for database schema validity
Following up on #12598, I'll be working on tools to ensure that incompatible database table schema changes aren't introduced into our codebase.
#1 Updated by Boone Gorges over 1 year ago
https://github.com/cuny-academic-commons/cac/commit/f39822996fe5429cca11e1ad0b886cd90166fa2e introduces a framework for doing this kind of scan.
I've introduced a new PHPCS ruleset
CAC. This ruleset includes the PHPCompatibilityWP ruleset (which we were already using) and introduces a custom sniff RequirePrimaryKey. This setup allows us to add more sniffs in the future, both custom and off-the-shelf.
The RequirePrimaryKey sniff looks for strings of the form 'CREATE TABLE' (even those that are concatenated and/or interpolated) and then ensures that they have the text 'PRIMARY KEY' in them. This is not at all a perfect system - it's viable to certain kinds of false positives, and it will almost certainly miss problematic cases. But it's a starting place, and I will continue to work on it.