boyhagemann / storage
Requires
- particle/validator: ~2.0@dev
- ramsey/uuid: ~3.5
- rkr/php-mysql-query-builder: 0.1.*
- vlucas/phpdotenv: ~2.4
Requires (Dev)
- phpunit/phpunit: ~5.7
This package is not auto-updated.
Last update: 2024-10-27 03:52:23 UTC
README
This is a proof of concept of an immutable data storage system. No data will ever get mutated. Every change for both the data schema and the data itself is versioned.
This package can be used in any API framework.
Testing
Run vendor/bin/phpunit
to run all tests.
Quick Start
- Setup the Entity and a Record
$pdo = new PDO( ... ); $entity = new MysqlEntity($pdo); $record = new MysqlRecord($pdo);
-
Create a new entity
-
Insert a record
Drivers
By default, it ships with a Mysql driver.
But you can make your own driver, as long as it follows the interfaces.
The drivers must have a test file that extends the AbstractTest.php
.
Entities and Records
The package is divided in two concepts:
- Entities
- Records
Entity
An Entity reflects a table in MySQL.
It holds the structure of the data.
An Entity
has many Field
s that defines the structure.
This is what happens of something changes in an Entity or a Field:
- If an
Entity
changes, the version of theEntity
increments with 1. - If a
Field
changes, the version of theField
and itsEntity
increments with 1.
Record
A Record reflects a table row in MySQL.
Each Records has a unique _id
and holds the actual data.
A Record
has many Value
s that makes up the data.
This is what happens of something changes in a Record:
- If the changes of the Record differ from the last version, then the version of the
Record
increments with 1. - If a provided
Value
differs from the last version of this Value, the version for this Value increments with 1.