PHPackages                             bytepark/lib-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. bytepark/lib-migration

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

bytepark/lib-migration
======================

bytepark Component - Lightweight and flexible database schema and data migration toolkit

1.0.7(10y ago)1573MITPHP

Since Dec 11Pushed 10y ago16 watchersCompare

[ Source](https://github.com/bytepark/lib-migration)[ Packagist](https://packagist.org/packages/bytepark/lib-migration)[ Docs](http://www.bytepark.de)[ RSS](/packages/bytepark-lib-migration/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (9)Used By (0)

Database migration library
==========================

[](#database-migration-library)

Status
------

[](#status)

[![alt text](https://camo.githubusercontent.com/16fe3b5e9d2b079096c530f806173ed56ac45295cc5b6e97a44e47505bf88c6d/68747470733a2f2f6170692e7472617669732d63692e6f72672f627974657061726b2f6c69622d6d6967726174696f6e2e737667 "build status")](https://travis-ci.org/bytepark/lib-migration)

Lightweight database migration library.

The lib-migration component offers an easy to use API for database migrations controlled from within a project or application, not differentiating between structural or data migrations. The migration workload itself is pure SQL and is currently **not** verified by the library. The correct syntax and integrity checks are the responsibility of the user.

TODOS / Open Features
---------------------

[](#todos--open-features)

- Add a CLI implementation (at best as own component) See
- Add SQL Schema abstraction for database repository / connection
- Add some error messaging/logging facility
- Rename Repository interface to Location?
- Rename Manager to something better!!!

Concept
-------

[](#concept)

The library defines the public interfaces Connection, Repository and Lock. The instance of the Connection interface provides access to the database that is the subject of change, i.e. the database where one wants to migrate against. Implementations of the following databases are bundled in the component using PDO:

- Sqlite memory database
- Sqlite file database
- MySQL database

The instance of the Repository interface represent a location where the single work units are persisted. Therefore two repositories must be specified, one representing the source of all the migrations and one representing the history of all already migrated work units. Implementations of two filesystem, a database and a memory located repository are bundled.

When you want to persist in the filesystem, you can choose between a *flat* and a *grouped* directory structure. The work units are save in one directory in the first case and a two subdirectory deep structure - depending on the unique ID of the work unit - in the latter case.

As the library is to be used in the context of an application, and as applications are nowadays often parallelized, the Manager depends on a locking mechanism to ensure mutual exclusive execution of the database migrations not already present in the history repository.

The four instances are injected during construction into the Manager class which delegates the migration process.

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

[](#installation)

The recommended way to install lib-migration is through [Composer](http://getcomposer.org).

```
# Install Composer
curl -sS https://getcomposer.org/installer | php
```

Next, run the Composer command to install the latest stable version of lib-migration:

```
composer require bytepark/lib-migration
```

After installing, you need to require Composer's autoloader:

```
require 'vendor/autoload.php';
```

Usage
-----

[](#usage)

### Example Filesystem to DB

[](#example-filesystem-to-db)

The migration process scans a defined directory for files with the (default) file extension *.mig*. The set of files is then diffed against the already migrated set, which is, in the example, persisted in a database table.

### Migration file requirements

[](#migration-file-requirements)

The single migrations should be named in some descending sortable syntax to express weak dependencies. Recommended is the naming of the files including a date, datetime or timestamp prefix, i.e. 19700101-some-text.mig. The migrations will be processed in the given order of the directory scan.

The content of the specific files is the pure SQL queries to execute against the database.

Bridging Components
-------------------

[](#bridging-components)

Will soon be linked here. Currently we know that the following bridges will be provided, each depending on this component:

- a CLI bridge
- a Silex service provider
- a Redaxo4 CMS bridge
- a Symfony2 Bundle
- a symfony1 plugin

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 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 ~66 days

Recently: every ~116 days

Total

8

Last Release

3700d ago

### Community

Maintainers

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

---

Top Contributors

[![masthowasli](https://avatars.githubusercontent.com/u/318175?v=4)](https://github.com/masthowasli "masthowasli (9 commits)")[![fbatschi](https://avatars.githubusercontent.com/u/10141857?v=4)](https://github.com/fbatschi "fbatschi (1 commits)")

---

Tags

migrationdatabaselibrary

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

64401.8k10](/packages/rah-danpu)[dragon-code/migrate-db

Easy data transfer from one database to another

15717.4k](/packages/dragon-code-migrate-db)[doesntmattr/mongodb-migrations-bundle

Symfony MongoDBMigrationsBundle

23484.5k1](/packages/doesntmattr-mongodb-migrations-bundle)[hzhihua/yii2-dump

Generate the schema from an existing database

1828.5k1](/packages/hzhihua-yii2-dump)[smrtr/mysql-version-control

A crude version control system for mysql written in php

221.4k](/packages/smrtr-mysql-version-control)[codengine/laravel-custom-migrations

Custom Migrations for Laravel

131.3k](/packages/codengine-laravel-custom-migrations)

PHPackages © 2026

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