mikejestes / scheezy
Translate yaml schema definitions into real actual databases
Installs: 8 468
Dependents: 0
Suggesters: 1
Security: 0
Stars: 3
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: >=7.3.0
- symfony/yaml: 5.*.*
Requires (Dev)
- phpunit/phpunit: 9.*.*
README
A PHP 5.3+ library to translate yaml schema definitions into real, actual databases. You could view this as an intentional anti-pattern to database migration techniques. For when you don't want to migrate up and down, just dictate the database schema.
Installation
Add to your composer.json
file:
{ "require": { "mikejestes/scheezy": "*" }, ... }
Then download and run composer:
curl -s https://getcomposer.org/installer | php
php composer.phar install
Schema Definition Syntax
table: store columns: id: name: type: string length: 80 email: index: unique active: type: boolean allow_null: true user_count: type: integer index: true website: created: type: datetime updated: type: timestamp calendar: type: date paragraph: type: text price: type: decimal latitude: type: decimal precision: 9 scale: 6 status: type: enum values: - approved - disabled - draft
A column defaults to string type, unless the name is id
which is given an integer type, a primary key, and auto_increment.
Database engines
Currently supports mysql through PDO classes.
API
Load a directory of .yaml
files
$pdoHandle = new PDO("mysql:host=localhost;dbname=scheezy_test", 'root', ''); $schema = new \Scheezy\Schema($pdoHandle); $schema->loadDirectory(dirname(__FILE__) . '/schemas/'); $schema->synchronize();
Load a single .yaml
file
$schema = new \Scheezy\Schema($pdoHandle); $schema->loadFile('/path/to/ponys.yaml'); $schema->synchronize();
Alternatives
For actual migration style (up, down, rollback) try one of these: