Skip to content

feat: add log:init-db command to create the log table - #89

Merged
tyrsson merged 2 commits into
2.0.xfrom
feat/log-init-db
Sep 30, 2026
Merged

tyrsson merged 2 commits into
2.0.xfrom
feat/log-init-db

Conversation

@tyrsson

@tyrsson tyrsson commented Sep 30, 2026

Copy link
Copy Markdown
Member

Adds a log:init-db console command that creates the table PhpDbHandler writes to. Nothing created it before, so a failed login in a host app 500d with Table ... log doesn't exist.

  • Registered under Webware\Console\ConsoleInterface::class for webware-console discovery (lazy, same as acl and usermanager).
  • The table name is read the way PhpDbHandlerFactory reads it (configured logger table, else the default), so command and handler agree.
  • --drop drops and recreates; without it the command is idempotent (CREATE TABLE IF NOT EXISTS) and keeps rows.
  • webware-console is a require-dev (analysis and tests) and a suggest. 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.

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

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

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>
@tyrsson
tyrsson merged commit 4659179 into 2.0.x Sep 30, 2026
12 checks passed
@tyrsson
tyrsson deleted the feat/log-init-db branch September 30, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a console command to create the log table schema (parity with user:init-db and acl:init-db)

1 participant