PHPackages                             locomotivemtl/charcoal-contrib-database-migrator - 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. locomotivemtl/charcoal-contrib-database-migrator

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

locomotivemtl/charcoal-contrib-database-migrator
================================================

Charcoal service provider for database migrations.

0.1.1(4y ago)046MITPHPPHP &gt;7.1CI failing

Since Aug 27Pushed 4y ago12 watchersCompare

[ Source](https://github.com/locomotivemtl/charcoal-contrib-database-migrator)[ Packagist](https://packagist.org/packages/locomotivemtl/charcoal-contrib-database-migrator)[ Docs](https://github.com/locomotivemtl/charcoal-contrib-database-migrator/)[ RSS](/packages/locomotivemtl-charcoal-contrib-database-migrator/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

Charcoal DatabaseMigrator
=========================

[](#charcoal-databasemigrator)

[![License](https://camo.githubusercontent.com/088df046a24402a99bf790105daedff7dff83a7e174440a3b7f063c942dabea4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d64617461626173652d6d69677261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/locomotivemtl/charcoal-contrib-database-migrator)[![Latest Stable Version](https://camo.githubusercontent.com/16188a8d4ec696afc34b1beeb5b09d522ed3a20dc739f2906725e3aa25ba78ae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d64617461626173652d6d69677261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/locomotivemtl/charcoal-contrib-database-migrator)[![Code Quality](https://camo.githubusercontent.com/7e915979c6d7135fe6ca91a61cdfd2b9612894c9a29ed213c8bd593952dc6fcc/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d64617461626173652d6d69677261746f722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/locomotivemtl/charcoal-contrib-database-migrator/)[![Coverage Status](https://camo.githubusercontent.com/5409eb0d933af44fde371a70f5e85a3b031f538f092abe6591b461762809efec/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d64617461626173652d6d69677261746f722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/locomotivemtl/charcoal-contrib-database-migrator)[![Build Status](https://camo.githubusercontent.com/3d1d25362b5e86e8968b828139025107390be7a0ecd38680df3b5979dd9572dc/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d64617461626173652d6d69677261746f722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/locomotivemtl/charcoal-contrib-database-migrator)

A [Charcoal](https://packagist.org/packages/locomotivemtl/charcoal-app) service provider my cool feature.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
    - [Dependencies](#dependencies)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Running the migration](#running-the-migration)
    - [Creating new Migrations](#creating-new-migrations)
    - [Injecting Migrations to the migrator](#injecting-migrations-to-the-migrator)
- [Development](#development)
    - [API Documentation](#api-documentation)
    - [Development Dependencies](#development-dependencies)
    - [Coding Style](#coding-style)
- [Credits](#credits)
- [License](#license)

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

[](#installation)

The preferred (and only supported) method is with Composer:

```
$ composer require locomotivemtl/charcoal-contrib-database-migrator
```

### Dependencies

[](#dependencies)

#### Required

[](#required)

- [**PHP 7.2+**](https://php.net): *PHP 7.3+* is recommended.

#### PSR

[](#psr)

- [**PSR-7**](https://www.php-fig.org/psr/psr-7/): Common interface for HTTP messages. Fulfilled by Slim.
- [**PSR-11**](https://www.php-fig.org/psr/psr-11/): Common interface for dependency containers. Fulfilled by Pimple.

Configuration
-------------

[](#configuration)

In your project's config file, require the migrator module like so :

```
{
    "modules": {
        "charcoal/migrator/migrator": {}
    }
}
```

Optionally, you can also override some migrator configurations in the project's config file using the `database.migrator` key :

```
{
    "database": {
        "migrator": {
            "migrations": {
                "search_paths": [
                    "path/to/some/migrations",
                    "path/to/some/custom/migrations"
                ]
            }
        }
    }
}
```

Usage
-----

[](#usage)

### Running the migration

[](#running-the-migration)

Simply run this command in the console to lunch the migration process

```
$ vendor/bin/charcoal admin/database/migrate
```

The CLI UI will guide you step by step.

### Creating new Migrations

[](#creating-new-migrations)

A migration should always extend [**AbstractMigration**](src/Charcoal/DatabaseMigrator/AbstractMigration.php)

[**MigrationYYYYMMDDHHMMSS.stub**](database/migration/Stub/MigrationYYYYMMDDHHMMSS.stub) can be used as a starting point when creating new migrations. Just copy and paste it the package in need of a new migration.

A migration should always be named `MigrationYYYYMMDDHHMMSS.php` to facilitate readability.

A migration file consist of a PHP class which follows these guidelines :

- Contains the timestamp of the commit this migration is fixing in the class name prefixed with `migration`
- Have an `up` and optionally `down` methods for the migration tool to process the migration when going up in version or down.
- Have a `descripion` method to briefly document the migration

you can implement the setDependencies method on a migration.

```
     /**
     * Inject dependencies from a DI Container.
     *
     * @param Container $container A Pimple DI service container.
     * @return void
     */
    protected function setDependencies(Container $container)
    {
        // This method is a stub.
        // Reimplement in children method to inject dependencies in your class from a Pimple container.
    }
```

You can also use the `init()` function to process data that is both needed in `up` and `down` methods.

### Injecting Migrations to the migrator

[](#injecting-migrations-to-the-migrator)

As long as the migration follows the guidelines described above, it'll be automatically parsed by the migrator. No need to do anything more than that.

Development
-----------

[](#development)

To install the development environment:

```
$ composer install
```

To run the scripts (phplint, phpcs, and phpunit):

```
$ composer test
```

### API Documentation

[](#api-documentation)

- The auto-generated `phpDocumentor` API documentation is available at:

- The auto-generated `apigen` API documentation is available at:
    [https://codedoc.pub/locomotivemtl/charcoal-contrib-database-migrator/master/](https://codedoc.pub/locomotivemtl/charcoal-contrib-database-migrator/master/index.html)

### Development Dependencies

[](#development-dependencies)

- \[php-coveralls/php-coveralls\]\[phpcov\]
- \[phpunit/phpunit\]\[phpunit\]
- \[squizlabs/php\_codesniffer\]\[phpcs\]

### Coding Style

[](#coding-style)

The charcoal-contrib-database-migrator module follows the Charcoal coding-style:

- [*PSR-1*](https://www.php-fig.org/psr/psr-1/)
- [*PSR-2*](https://www.php-fig.org/psr/psr-2/)
- [*PSR-4*](https://www.php-fig.org/psr/psr-4/), autoloading is therefore provided by *Composer*.
- [*phpDocumentor*](http://phpdoc.org/) comments.
- [phpcs.xml.dist](phpcs.xml.dist) and [.editorconfig](.editorconfig) for coding standards.

> Coding style validation / enforcement can be performed with `composer phpcs`. An auto-fixer is also available with `composer phpcbf`.

Credits
-------

[](#credits)

- [Locomotive](https://locomotive.ca/)

License
-------

[](#license)

Charcoal is licensed under the MIT license. See [LICENSE](LICENSE) for details.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

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

Total

2

Last Release

1797d ago

### Community

Maintainers

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

---

Top Contributors

[![JoelAlphonso](https://avatars.githubusercontent.com/u/10762266?v=4)](https://github.com/JoelAlphonso "JoelAlphonso (40 commits)")

---

Tags

charcoal

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/locomotivemtl-charcoal-contrib-database-migrator/health.svg)

```
[![Health](https://phpackages.com/badges/locomotivemtl-charcoal-contrib-database-migrator/health.svg)](https://phpackages.com/packages/locomotivemtl-charcoal-contrib-database-migrator)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[locomotivemtl/charcoal-cms

Charcoal CMS (Content Management System) Module

529.0k3](/packages/locomotivemtl-charcoal-cms)[orchestra/database

Database Component for Orchestra Platform

201.4M578](/packages/orchestra-database)[locomotivemtl/charcoal-app

Charcoal application, based on Slim 3

1320.3k12](/packages/locomotivemtl-charcoal-app)[locomotivemtl/charcoal-admin

The Charcoal Administration Dashboard

1110.8k8](/packages/locomotivemtl-charcoal-admin)

PHPackages © 2026

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