formal/migrations

SQL and Commands migrations

Maintainers

Package info

github.com/formal-php/migrations

Homepage

Issues

pkg:composer/formal/migrations

Statistics

Installs: 417

Dependents: 0

Suggesters: 0

Stars: 0

2.0.0 2026-04-04 16:51 UTC

This package is auto-updated.

Last update: 2026-04-05 09:35:23 UTC


README

CI codecov Type Coverage

This library is a simple one way migration system.

You can run both SQL and Commands migrations.

Installation

composer require formal/migrations

Usage

use Formal\Migrations\{
    Factory,
    Failure,
}
use Innmind\OperatingSystem\Factory as OS;
use Innmind\Url\{
    Url,
    Path,
};

$dsn = Url::of('mysql://user:pwd@127.0.0.1:3306/database');

Factory::of(OS::build())
    ->storeVersionsInDatabase($dsn)
    ->unwrap()
    ->sql()
    ->files(Path::of('migrations/folder/'))
    ->migrate($dsn)
    ->match(
        static fn() => print('Everything has been migrated'),
        static fn(Failure $failure) => printf(
            'Migrations failed with the message : %s',
            $failure->error()->getMessage(),
        ),
    );

Documentation

Full documentation available here.