Stop auto-creating schema on store construction - #10
Merged
Conversation
`SqlEventStore` and `SqlRedeliveryStore` previously created their tables
on first boot inside the constructor. That raced with host applications
that own their own migration tooling and could trigger DDL at unexpected
times.
Constructors are now no-ops. Two installation paths are documented:
versioned DDL templates in `migrations/{mysql,sqlite}/` for host
migration tools, or the existing `Schema::create()` helper for opt-in
boot-time setup. Tests now invoke `Schema::create()` explicitly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jcviljoen
marked this pull request as ready for review
May 16, 2026 20:43
Future schema changes now ship as new numbered files in `migrations/`; host migration tools handle ordering and idempotency. Nothing left for the package to build, so the item doesn't belong on the roadmap. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
SqlEventStore::__constructandSqlRedeliveryStore::__constructno longer callensure*Schema(). The stores assume their tables already exist.migrations/{mysql,sqlite}/directory ships versioned, pure-DDL files (0001_create_event_outbox.sql,0001_create_event_outbox_redelivery.sql) for host migration tools to consume. Future schema changes will land here as new numbered files.Schema/*::create()helpers are unchanged and remain the explicit opt-in path for projects without their own migration tooling. They stay idempotent.Schema::create($pdo)insetUp(). The two_schema_is_idempotent_across_multiple_instantiationstests are rewritten as_schema_create_is_idempotentagainst the helper directly.Motivation
Auto-create-on-construct raced with host migration tooling — see hivesper/vesper-identity-api#191, which had to work around this package triggering DDL at boot. With this change, schema installation is a deliberate act in whichever system the host already uses.
Breaking change
Existing consumers will get "table doesn't exist" errors on first boot after upgrading until they either:
vendor/hivesper/php-events/migrations/{driver}/0001_*.sql(recommended), orMysqlEventStoreSchema::create(\$pdo)(andMysqlRedeliverySchema::create(\$pdo)if using redelivery) once at boot.🤖 Generated with Claude Code