PHPackages                             hhpack/migrate - 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. hhpack/migrate

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

hhpack/migrate
==============

Lightweight migration tool for Hack

2.2.1(7y ago)112[1 issues](https://github.com/hhpack/migrate/issues)MITShell

Since May 15Pushed 7y agoCompare

[ Source](https://github.com/hhpack/migrate)[ Packagist](https://packagist.org/packages/hhpack/migrate)[ RSS](/packages/hhpack-migrate/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (8)Versions (29)Used By (0)

migrate
=======

[](#migrate)

[![CircleCI](https://camo.githubusercontent.com/57c6a4af33ee27a74741e3c534307f77ead7e0b49dc6a2d7e1629498b8fc6423/68747470733a2f2f636972636c6563692e636f6d2f67682f68687061636b2f6d6967726174652f747265652f6d61737465722e7376673f7374796c653d737667)](https://circleci.com/gh/hhpack/migrate/tree/master)

Basic usage
-----------

[](#basic-usage)

First place the **database.json** of the configuration file in the **config** directory.
Please specify the setting referring to the following.

- **type** - the type of migration, it only supports **SQL base**.
- **path** - the directory of the migration file.
- **enviroments** - Database connection setting for environment.

```
{
  "type": "sql",
  "path": "db/migrate",
  "enviroments": {
    "development": {
      "host": "localhost",
      "port": 3306,
      "name": "migrate",
      "user": { "ENV": "DB_USERNAME" },
      "password": { "ENV": "DB_PASSWORD" }
    }
  }
}
```

### Create a database

[](#create-a-database)

You can run the create command to create the database.

```
vendor/bin/migrate create
```

### Generate a migration file

[](#generate-a-migration-file)

Use the **gen command** to generate a migration file.

```
vendor/bin/migrate gen create-users
```

### Upgrade of schema

[](#upgrade-of-schema)

Use the up command to upgrade the schema.
You can upgrade to a specific version by specifying the **--to** option.

```
vendor/bin/migrate up
```

or

```
vendor/bin/migrate up --to=20150824010439-create-users
```

### Downgrade of schema

[](#downgrade-of-schema)

To downgrade to the specified version, use the down command.

```
vendor/bin/migrate down 20150824010439-create-users
```

### Reset of schema

[](#reset-of-schema)

Restore all applied migrations.

```
vendor/bin/migrate reset
```

### Drop database

[](#drop-database)

You can delete the database with the following command.

```
vendor/bin/migrate drop
```

### Migrator

[](#migrator)

Current version supports SQL based migration.

```
use HHPack\Migrate\Migrator;
use HHPack\Migrate\SqlMigrationLoader;
use HHPack\Migrate\DatabaseClient;

$mysql = await DatabaseClient::createConnection('mysql:dbname=migrate;port=3306', 'migrate', 'migrate');
$loader = new SqlMigrationLoader(__DIR__ . '/sql/migrations');

$migrator = new Migrator($loader, $mysql);

await $migrator->upgrade();
```

### Downgrade of schema

[](#downgrade-of-schema-1)

```
use HHPack\Migrate\Migrator;
use HHPack\Migrate\SqlMigrationLoader;
use HHPack\Migrate\DatabaseClient;

$mysql = await DatabaseClient::createConnection('mysql:dbname=migrate;port=3306', 'migrate', 'migrate');
$loader = new SqlMigrationLoader(__DIR__ . '/sql/migrations');

$migrator = new Migrator($loader, $mysql);

await $migrator->downgrade('20150825102100-create-posts');
```

Run the test
------------

[](#run-the-test)

1. Create a database

    ```
     CREATE USER 'migrate'@'localhost' IDENTIFIED BY 'migrate';

    ```
2. Create a user

    ```
     GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON migrate.* TO 'migrate'@'localhost';

    ```
3. Execute unit test

    You can run the test with the following command.

    ```
     composer install
     composer test

    ```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity74

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

Recently: every ~99 days

Total

25

Last Release

2628d ago

Major Versions

0.5.1 → 1.0.02017-02-19

1.2.0 → 2.0.0-beta12017-08-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/70c299d6d6015ee714954aa05e4d0e9c7b1d31318a5d7db5e9bb4e1f70f78afc?d=identicon)[holyshared](/maintainers/holyshared)

---

Top Contributors

[![holyshared](https://avatars.githubusercontent.com/u/167190?v=4)](https://github.com/holyshared "holyshared (184 commits)")

---

Tags

dbhacklanghhvmmigratemysqlmigrationmysqldblightweight

### Embed Badge

![Health badge](/badges/hhpack-migrate/health.svg)

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

###  Alternatives

[catfan/medoo

The lightweight PHP database framework to accelerate development

4.9k1.5M203](/packages/catfan-medoo)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4563.1M37](/packages/aura-sqlquery)[envms/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

921530.0k13](/packages/envms-fluentpdo)[lichtner/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

922281.8k6](/packages/lichtner-fluentpdo)[fpdo/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

922249.3k8](/packages/fpdo-fluentpdo)[odan/phinx-migrations-generator

Migration generator for Phinx

233889.6k24](/packages/odan-phinx-migrations-generator)

PHPackages © 2026

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