hectororm / migration
Hector Migration
Requires
- php: ^8.0
- ext-pdo: *
- hectororm/connection: v1.6.0
- hectororm/schema: v1.6.0
Requires (Dev)
None
Suggests
- hectororm/query: Required for DbTracker
- league/flysystem: Required for FlysystemTracker (^3.0)
- psr/container: Required for container-based migration instantiation in DirectoryProvider (^1.0 || ^2.0)
- psr/event-dispatcher: For migration lifecycle events (^1.0)
- psr/log: For migration lifecycle logging (^1.0 || ^2.0 || ^3.0)
Provides
None
Conflicts
None
Replaces
None
README
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.