Search by

cycle / schema-migrations-generator

wolfy-j

Cycle ORM Migration generation

Package info

github.com/cycle/schema-migrations-generator

Chat

Documentation

pkg:composer/cycle/schema-migrations-generator

Fund package maintenance!

cycle

Statistics

Installs: 480 585

Dependents: 24

Suggesters: 3

Stars: 3

Open Issues: 3

2.4.0 2026-11-21 12:33 UTC

This package is auto-updated.

Last update: 2026-11-22 10:16:05 UTC


README

CycleORM Logo

Migration generator for Cycle ORM

Documentation Sponsor Discord

Psalm Level Type Coverage Codecov Mutation testing badge


The migration generator creates a set of migration files for Cycle ORM during schema compilation. You can edit the generated migrations by hand before running them.

Get Started

Requirements

  • PHP 8.2+

Installation

composer require cycle/schema-migrations-generator

PHP Latest Version on Packagist License Total Downloads

Configuration

use Cycle\Migrations;
use Cycle\Schema\Registry;
use Cycle\Database;
use Cycle\Database\Config;
use Cycle\Schema\Generator\Migrations\GenerateMigrations;

$dbal = new Database\DatabaseManager(new Config\DatabaseConfig([
    'default' => 'default',
    'databases' => [
        'default' => [
            'connection' => 'sqlite'
        ]
    ],
    'connections' => [
        'sqlite' => new Config\SQLiteDriverConfig(
            connection: new Config\SQLite\MemoryConnectionConfig(),
            queryCache: true,
        ),
    ]
]));

$config = new Migrations\Config\MigrationConfig([
    'directory' => __DIR__ . '/migrations/',
    'table' => 'migrations',
]);

$migrator = new Migrations\Migrator(
    $config,
    $dbal, 
    new Migrations\FileRepository($config)
);

$registry = new Registry($dbal);
$registry->register(....);

$generator = new GenerateMigrations(
    $migrator->getRepository(),
    $migrator->getConfig()
);

Running

The generator creates the migrations needed to sync the database schema with the desired state. Each database receives its own migration.

$generator->run($registry);