Repository navigation
feat: add log:init-db command to create the log table - #89
Merged
Merged
Conversation
The database log handler inserts into a table nothing created, so a failed write surfaced as a 500 in host apps. Add a log:init-db console command, registered under ConsoleInterface::class for webware-console discovery, that creates the table the handler writes to. The table name is read the way PhpDbHandlerFactory reads it, so the command and handler always agree. The DDL is verified against the existing fixture schema on a real MySQL, and --drop recreates the table. webware-console is a dev dependency (used to analyse and test the command) and a suggestion for hosts that run it. Signed-off-by: Joey Smith <jsmith@webinertia.net>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
CI lint (literal-named-argument) rejected the positional preg_replace arguments. Signed-off-by: Joey Smith <jsmith@webinertia.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
log:init-dbconsole command that creates the tablePhpDbHandlerwrites to. Nothing created it before, so a failed login in a host app 500d withTable ... log doesn't exist.Webware\Console\ConsoleInterface::classfor webware-console discovery (lazy, same as acl and usermanager).PhpDbHandlerFactoryreads it (configured logger table, else the default), so command and handler agree.--dropdrops and recreates; without it the command is idempotent (CREATE TABLE IF NOT EXISTS) and keeps rows.webware-consoleis arequire-dev(analysis and tests) and asuggest. The lock gained 7 packages and changed none.analysis-baseline.toml: the two existing entries were reworded because the declared config types grew; count (22) and files are unchanged.Verification: format, lint, analyze and guard clean. Unit 100 tests; integration 10 tests against a real MySQL 9.7, including a column-by-column comparison of the created table with the fixture the handler is tested against, and a handler write into it. Infection scoped to
src/Console: 46 mutants, 0 escaped.No release is needed to land this, but hosts need a release of webware-log to get the command without a path repo.