PHPackages                             byjg/migration-cli - 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. byjg/migration-cli

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

byjg/migration-cli
==================

Simple library in PHP for database version control. Supports Sqlite, MySql, Sql Server and Postgres.

5.0.1(10mo ago)1025.2k↓40.4%4[2 issues](https://github.com/byjg/php-migration-cli/issues)MITPHPPHP &gt;=8.1 &lt;8.4CI failing

Since Nov 29Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/byjg/php-migration-cli)[ Packagist](https://packagist.org/packages/byjg/migration-cli)[ GitHub Sponsors](https://github.com/byjg)[ RSS](/packages/byjg-migration-cli/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (14)Used By (0)

Database Migrations (CLI)
=========================

[](#database-migrations-cli)

[![Build Status](https://github.com/byjg/php-migration-cli/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/byjg/php-migration-cli/actions/workflows/phpunit.yml)[![Opensource ByJG](https://camo.githubusercontent.com/425c1bbccc0f292bf4d20569ae74a6b2e384fd648f1af8911bc61de9a8dcfc0b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f70656e736f757263652d62796a672d737563636573732e737667)](http://opensource.byjg.com)[![GitHub source](https://camo.githubusercontent.com/88e61eb211719144efdd570290a0456b6e13099c2df8d973f1bb43fe33bf0039/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769746875622d736f757263652d696e666f726d6174696f6e616c3f6c6f676f3d676974687562)](https://github.com/byjg/php-migration-cli/)[![GitHub license](https://camo.githubusercontent.com/7bb8edb7bf5f5c5d814e2ea16e4dbe643e2be2b049aa12983b1052185bf1728f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f62796a672f7068702d6d6967726174696f6e2d636c692e737667)](https://opensource.byjg.com/opensource/licensing.html)[![GitHub release](https://camo.githubusercontent.com/a308b3176fba3900ededaaadb41c44993cc3f9706725e3f6906f44da7f99cda1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62796a672f7068702d6d6967726174696f6e2d636c692e737667)](https://github.com/byjg/php-migration-cli/releases/)

This is a simple library written in PHP for database version control. Currently supports SQLite, MySQL, SQL Server and PostgreSQL.

Database Migration can be used as:

- Command Line Interface
- PHP Library to be integrated in your functional tests
- Integrated in your CI/CD independent of your programming language or framework

Important Note
--------------

[](#important-note)

This package is the **command line interface** of ByJG PHP Migration.

**Key Points:**

- This CLI tool requires PHP to run, but **your project doesn't need to be written in PHP**
- You can use this tool with any programming language or framework
- Perfect for CI/CD pipelines and database versioning independent of your stack

**For PHP API Integration:**If you want to integrate migrations directly into your PHP code (e.g., for automated testing or programmatic control), use the core migration library instead:

- **PHP API**: [byjg/migration](https://github.com/byjg/migration) - Full PHP library with programmatic API
- **CLI Tool** (this package): [byjg/migration-cli](https://github.com/byjg/php-migration-cli) - Command line interface only

For complete information about the migration system, architecture, and advanced usage, visit the core project documentation:

Installing
----------

[](#installing)

```
composer require 'byjg/migration-cli'
```

Documentation
-------------

[](#documentation)

- [Getting Started](docs/getting-started.md) - Installation, configuration, and environment variables
- [Commands Reference](docs/commands.md) - Detailed documentation for all available commands
- [Migration Structure](docs/migration-structure.md) - How to organize and write migration files
- [Examples](docs/examples.md) - Practical examples and CI/CD integration

Quick Start
-----------

[](#quick-start)

The basic usage is:

```
vendor/bin/migrate  --path= uri://connection
```

**Connection String Examples:**

- SQLite: `sqlite:///path/to/my.db`
- MySQL: `mysql://user:password@server/database`
- PostgreSQL: `pgsql://user:password@server/database`
- SQL Server: `dblib://user:password@server/database`

**Using Environment Variables:**

```
export MIGRATE_CONNECTION=sqlite:///path/to/my.db
export MIGRATE_PATH=/path/to/migrate_files
vendor/bin/migrate update
```

Or use a `.env` file:

```
MIGRATE_CONNECTION=sqlite:///path/to/my.db
MIGRATE_PATH=/path/to/migrate_files
```

Available Commands
------------------

[](#available-commands)

The migration tool provides the following commands:

CommandDescription`create`Create the directory structure for migrations`install`Install or upgrade the migration version table in an existing database`version`Get the current database version`update`Intelligently migrate up or down based on current version`up`Migrate up to a newer version`down`Migrate down to an older version`reset`Create a fresh database from base.sql and apply all migrations### Command Options

[](#command-options)

All commands (except `create`) support these options:

- `--path, -p`: Define the path where base.sql and migration scripts are located
- `--up-to, -u`: Specify a target version for migration
- `--no-base`: Skip checking for base.sql file
- `-v, -vv, -vvv`: Increase verbosity level

### Quick Examples

[](#quick-examples)

```
# Create migration structure
vendor/bin/migrate create /path/to/migrations

# Install version control in existing database
vendor/bin/migrate install mysql://user:pass@localhost/myapp

# Check current version
vendor/bin/migrate version mysql://user:pass@localhost/myapp

# Update to latest version
vendor/bin/migrate update mysql://user:pass@localhost/myapp

# Update to specific version
vendor/bin/migrate update --up-to=10 mysql://user:pass@localhost/myapp

# Reset database (WARNING: destructive!)
vendor/bin/migrate reset --yes mysql://user:pass@localhost/myapp
```

Environment Variables
---------------------

[](#environment-variables)

VariableDescriptionDefault`MIGRATE_CONNECTION`Database connection string-`MIGRATE_PATH`Path to migration filesCurrent directory`MIGRATE_TABLE`Name of the migration version table`migration_version``MIGRATE_DISABLE_RESET`Disable the reset command`false`Related Projects
----------------

[](#related-projects)

- **[Migration Core Library](https://github.com/byjg/migration)** - PHP API for programmatic migration control (use this for PHP code integration)
- [AnyDataset DB](https://github.com/byjg/anydataset-db) - Database abstraction layer
- [Micro ORM](https://github.com/byjg/micro-orm) - Lightweight ORM
- [PHP Rest Template](https://github.com/byjg/php-rest-template) - REST client library

Dependencies
------------

[](#dependencies)

 ```
flowchart TD
    byjg/migration-cli --> byjg/migration
    byjg/migration-cli --> symfony/console
    byjg/migration-cli --> vlucas/phpdotenv
```

      Loading ---

[Open source ByJG](http://opensource.byjg.com)

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance58

Moderate activity, may be stable

Popularity35

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 90% 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 ~230 days

Recently: every ~167 days

Total

12

Last Release

190d ago

Major Versions

4.9.1 → 5.0.02024-10-29

5.0.1 → 6.0.x-dev2025-11-09

PHP version history (4 changes)4.2.0PHP &gt;=7.2

4.9.1PHP &gt;=7.4

5.0.0PHP &gt;=8.1 &lt;8.4

6.0.x-devPHP &gt;=8.1 &lt;8.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/981924?v=4)[Joao Gilberto Magalhaes](/maintainers/byjg)[@byjg](https://github.com/byjg)

---

Top Contributors

[![byjg](https://avatars.githubusercontent.com/u/981924?v=4)](https://github.com/byjg "byjg (54 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (4 commits)")[![Ahmed-Shaheen2](https://avatars.githubusercontent.com/u/40732680?v=4)](https://github.com/Ahmed-Shaheen2 "Ahmed-Shaheen2 (2 commits)")

###  Code Quality

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[worksome/foggy

Foggy is a tool for making database dumps with some data removed/changed.

26571.7k1](/packages/worksome-foggy)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[psx/sql

Generate type-safe PHP classes from your database

1773.4k4](/packages/psx-sql)[cable8mm/xeed

The Xeed is to generate new model, seed, Nova resource, database seed, factory and migration files for Laravel &amp; Nova based on data from the existing database table.

872.4k](/packages/cable8mm-xeed)[perplorm/perpl

Perpl is an improved and still maintained fork of Propel2, an open-source Object-Relational Mapping (ORM) for PHP.

203.7k](/packages/perplorm-perpl)

PHPackages © 2026

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