Search by

hectororm / migration

ElGigi

Hector Migration

Package info

github.com/hectororm/migration

Homepage

Issues

pkg:composer/hectororm/migration

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

v1.6.0 2026-10-17 23:38 UTC

This package is auto-updated.

Last update: 2026-10-17 23:40:28 UTC


README

Latest Version Packagist Dependency Version Software license

Note

This repository is a read-only split from the main HectorORM repository.

For contributions, issues, or more information, please visit the main HectorORM repository.

Do not open issues or pull requests here.

Hector Migration orchestrates database migrations for Hector ORM. It provides migration providers, trackers, and a transaction-safe runner built on top of the Plan system. Can be used independently of ORM.

Installation

You can install Hector Migration with Composer, it's the recommended installation.

$ composer require hectororm/migration

Documentation

CHECK migrations

use Hector\Migration\ReversibleMigrationInterface;
use Hector\Schema\Plan\Plan;

class RequireNonNegativePrice implements ReversibleMigrationInterface
{
    public function up(Plan $plan): void
    {
        $plan->alter('products')->addCheck('chk_price', 'price >= 0');
    }

    public function down(Plan $plan): void
    {
        $plan->alter('products')->dropCheck('chk_price');
    }
}

Use AutoCompiler, or explicit capabilities for offline MySQL/MariaDB compilation. For SQLite ALTER operations, pass a current schema from Hector\Schema\Generator\Sqlite to the runner. The runner refreshes supplied SQLite metadata between executed migrations.

The runner compiles the whole plan before executing SQL. SQLite rebuilds run in their own transaction: foreign-key checks are disabled beforehand, integrity is checked before commit, and the original setting is restored after success or failure. With DbTracker on the same connection, schema/data changes and tracking are committed or rolled back together. CHECK additions fail when SQLite session enforcement is disabled. MySQL/MariaDB DDL implicitly commits; a later failure can leave schema changes applied but untracked.

up(dryRun: true) and down(dryRun: true) compile and log SQL without executing migration statements or recording their application. Dry-run uses the available schema snapshot; it does not simulate earlier migrations.

For usage and examples, visit the official documentation on gethectororm.com.