prooph / pdo-event-store
Prooph PDO EventStore
Installs: 982 302
Dependents: 22
Suggesters: 6
Security: 0
Stars: 111
Watchers: 13
Forks: 56
Open Issues: 7
Requires
- php: ^7.3 | ^8.0
- ext-pdo: *
- prooph/event-store: ^v7.6
Requires (Dev)
- phpspec/prophecy: ^1.9
- phpspec/prophecy-phpunit: ^2.0
- phpunit/php-invoker: ^3.1
- phpunit/phpunit: ^9.3
- prooph/bookdown-template: ^0.2.3
- prooph/php-cs-fixer-config: ^0.4
- psr/container: ^1.0
- sandrokeil/interop-config: ^2.0.1
- satooshi/php-coveralls: ^1.0
Suggests
- ext-pdo_mysql: For usage with MySQL
- ext-pdo_pgsql: For usage with PostgreSQL
- psr/container: ^1.0 for usage of provided factories
- sandrokeil/interop-config: ^2.0.1 for usage of provided factories
Conflicts
- sandrokeil/interop-config: <2.0.1
- v1.15.1
- v1.15.0
- v1.14.2
- v1.14.1
- v1.14.0
- v1.13.0
- v1.12.0
- v1.11.2
- v1.11.1
- v1.11.0
- v1.10.5
- v1.10.4
- v1.10.3
- v1.10.2
- v1.10.1
- v1.10.0
- v1.9.1
- v1.9.0
- v1.9.0-BETA-2
- v1.9.0-BETA-1
- v1.8.4
- v1.8.3
- v1.8.2
- v1.8.1
- v1.8.0
- dev-master / 1.7.x-dev
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.0
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.1
- v1.4.0
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.1
- v1.0.0
- v1.0.0-beta4
- v1.0.0-beta3
- v1.0.0-beta2
- v1.0.0-beta1
This package is auto-updated.
Last update: 2024-10-29 05:09:44 UTC
README
PDO EventStore implementation for Prooph EventStore
Requirements
- PHP >= 7.3
- PDO_MySQL Extension or PDO_PGSQL Extension
For MariaDB you need server version >= 10.2.11.
Performance Impact: see [MariaDB Indexes and Efficiency](docs/variants.md#MariaDB Indexes and Efficiency)
For MySQL you need server version >= 5.7.9.
For Postgres you need server version >= 9.4.
Attention: Since v1.6.0 MariaDB Server has to be at least 10.2.11 due to a bugfix in MariaDB, see https://jira.mariadb.org/browse/MDEV-14402.
Setup
For MariaDB run the script in scripts/mariadb/01_event_streams_table.sql
on your server.
For MySQL run the script in scripts/mysql/01_event_streams_table.sql
on your server.
For Postgres run the script in scripts/postgres/01_event_streams_table.sql
on your server.
This will setup the required event streams table.
If you want to use the projections, run additionally the scripts scripts/mariadb/02_projections_table.sql
(for MariaDB), scripts/mysql/02_projections_table.sql
(for MySQL) or
scripts/postgres/02_projections_table.sql
(for Postgres) on your server.
Upgrade from 1.6 to 1.7
Starting from v1.7 the pdo-event-store uses optimized table schemas. The upgrade can be done in background with a script optimizing that process. A downtime for the database should not be needed. In order to upgrade your existing database, you have to execute:
- MariaDB
ALTER TABLE `event_streams` MODIFY `metadata` LONGTEXT NOT NULL;
ALTER TABLE `projections` MODIFY `position` LONGTEXT;
ALTER TABLE `projections` MODIFY `state` LONGTEXT;
Then for all event-streams (SELECT stream_name FROM event_streams
)
ALTER TABLE <stream_name> MODIFY `payload` LONGTEXT NOT NULL;
ALTER TABLE <stream_name> MODIFY `metadata` LONGTEXT NOT NULL,
- MySQL
nothing to upgrade
- Postgres
For all event-streams (SELECT stream_name FROM event_streams
)
ALTER TABLE <stream_name> MODIFY event_id UUID NOT NULL;
Additional note:
When using Postgres, the event_id has to be a valid uuid, so be careful when using a custom MetadataMatcher, as the event-store could throw an exception when passing a non-valid uuid (f.e. "foo") as uuid.
The migration is strongly recommended, but not required. It's fully backward-compatible. The change on Postgres is only a microoptimization, the change on MariaDB prevents errors, when the stored json gets too big.
Introduction
Tests
If you want to run the unit tests locally you need a runnging MySql server listening on port 3306
and a running Postgres server listening on port 5432
. Both should contain an empty database event_store_tests
.
Run Tests With Composer
MariaDb
$ vendor/bin/phpunit -c phpunit.xml.mariadb
MySql
$ vendor/bin/phpunit -c phpunit.xml.mysql
Postgres
$ vendor/bin/phpunit -c phpunit.xml.postgres
Run Tests With Docker Compose
MariaDb
docker-compose -f docker-compose-tests.yml run composer run-script test-mariadb --timeout 0; \
docker-compose -f docker-compose-tests.yml stop
MySql
docker-compose -f docker-compose-tests.yml run composer run-script test-mysql --timeout 0; \
docker-compose -f docker-compose-tests.yml stop
Postgres
docker-compose -f docker-compose-tests.yml run composer run-script test-postgres --timeout 0; \
docker-compose -f docker-compose-tests.yml stop
Support
- Ask questions on Stack Overflow tagged with #prooph.
- File issues at https://github.com/prooph/event-store/issues.
- Say hello in the prooph gitter chat.
Contribute
Please feel free to fork and extend existing or add new plugins and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.
License
Released under the New BSD License.