PHPackages                             fyre/migration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. fyre/migration

ActiveLibrary[Database &amp; ORM](/categories/database)

fyre/migration
==============

A database migration library.

v6.0.9(11mo ago)01283MITPHP

Since Jun 12Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreMigration)[ Packagist](https://packagist.org/packages/fyre/migration)[ RSS](/packages/fyre-migration/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (8)Versions (37)Used By (3)

FyreMigration
=============

[](#fyremigration)

**FyreMigration** is a free, open-source migration library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
- [Migrations](#migrations)
- [Migration Histories](#migration-histories)
- [Commands](#commands)
    - [Migrate](#migrate)
    - [Rollback](#rollback)

Installation
------------

[](#installation)

**Using Composer**

```
composer require fyre/migration

```

In PHP:

```
use Fyre\Migration\MigrationRunner;
```

Basic Usage
-----------

[](#basic-usage)

- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).
- `$loader` is a [*Loader*](https://github.com/elusivecodes/FyreLoader).
- `$connectionManager` is a [*ConnectionManager*](https://github.com/elusivecodes/FyreDB).
- `$forgeRegistry` is a [*ForgeRegistry*](https://github.com/elusivecodes/FyreForge).

```
$runner = new MigrationRunner($container, $loader, $connectionManager, $forgeRegistry);
```

**Autoloading**

It is recommended to bind the *MigrationRunner* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.

```
$container->singleton(MigrationRunner::class);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$runner = $container->use(MigrationRunner::class);
```

Methods
-------

[](#methods)

**Add Namespace**

Add a namespace for loading migrations.

- `$namespace` is a string representing the namespace.

```
$runner->addNamespace($namespace);
```

**Clear**

Clear all namespaces and migrations.

```
$runner->clear();
```

**Get Connection**

Get the [*Connection*](https://github.com/elusivecodes/FyreDB#connections).

```
$connection = $runner->getConnection();
```

**Get Forge**

Get the [*Forge*](https://github.com/elusivecodes/FyreForge#forges).

```
$forge = $runner->getForge();
```

**Get History**

Get the [*MigrationHistory*](#migration-histories).

```
$history = $runner->getHistory();
```

**Get Migrations**

Get all migrations.

```
$migrations = $runner->getMigrations();
```

**Get Namespaces**

Get the namespaces.

```
$namespaces = $runner->getNamespaces();
```

**Has Namespace**

Determine whether a namespace exists.

- `$namespace` is a string representing the namespace.

```
$hasNamespace = $php->hasNamespace($namespace);
```

**Migrate**

Migrate to the latest version.

```
$runner->migrate($latestVersion);
```

**Rollback**

Rollback to a previous version.

- `$batches` is a number representing the number of batches to rollback, and will default to *1*.
- `$steps` is a number representing the number of steps to rollback, and will default to *null*.

```
$runner->rollback($batches, $steps);
```

**Set Connection**

Set the [*Connection*](https://github.com/elusivecodes/FyreDB#connections).

- `$connection` is the [*Connection*](https://github.com/elusivecodes/FyreDB#connections).

```
$runner->setConnection($connection);
```

**Remove Namespace**

Remove a namespace.

- `$namespace` is a string representing the namespace.

```
$runner->removeNamespace($namespace);
```

Migrations
----------

[](#migrations)

Migrations can be created by extending the `\Fyre\Migration\Migration` class, prefixing the class name with "*Migration\_*".

To allow discovery of the migration, add the the namespace to the *MigrationRunner*.

**Down**

Perform a "down" migration.

```
$migration->down();
```

**Up**

Perform an "up" migration.

```
$migration->up();
```

Migration Histories
-------------------

[](#migration-histories)

**Add**

Add a migration version to the history.

- `$name` is a string representing the migration name.
- `$batch` is a number representing the batch number.

```
$history->add($name, $batch);
```

**All**

Get the migration history.

```
$all = $history->all();
```

**Delete**

Delete a migration from the history.

- `$name` is a string representing the migration name.

```
$history->delete($name);
```

**Get Next Batch**

Get the next batch number.

```
$batch = $history->getNextBatchNumber();
```

Commands
--------

[](#commands)

### Migrate

[](#migrate)

Perform database migrations.

- `--db` is the [*ConnectionManager*](https://github.com/elusivecodes/FyreDB) config key, and will default to `ConnectionManager::DEFAULT`.

```
$commandRunner->run('db:migrate', ['--db', 'default']);
```

### Rollback

[](#rollback)

Perform database rollbacks.

- `--db` is the [*ConnectionManager*](https://github.com/elusivecodes/FyreDB) config key, and will default to `ConnectionManager::DEFAULT`.
- `--batches` is the number of batches to rollback, and will default to *1*.
- `--steps` is the number of steps to rollback, and will default to *null*.

```
$commandRunner->run('db:rollback', ['--db', 'default', '--batches', '1', '--steps', 1]);
```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance50

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~32 days

Recently: every ~20 days

Total

36

Last Release

355d ago

Major Versions

v1.0.4 → v2.02023-07-30

v2.0.5 → v3.02023-12-17

v3.1.3 → v4.02024-08-11

v4.0.3 → v5.02024-11-08

v5.0.4 → v6.02025-03-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/fad81fd5941e3a637c8a5749d05ae3ed9314d5e2fee57f59c3d9ec3b41259c6b?d=identicon)[elusivecodes](/maintainers/elusivecodes)

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (31 commits)")

---

Tags

migrationphp

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/fyre-migration/health.svg)

```
[![Health](https://phpackages.com/badges/fyre-migration/health.svg)](https://phpackages.com/packages/fyre-migration)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
