PHPackages                             meritum/migrations - 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. [CLI &amp; Console](/categories/cli)
4. /
5. meritum/migrations

ActiveLibrary[CLI &amp; Console](/categories/cli)

meritum/migrations
==================

Schema migration runner with a CLI interface for the Meritum ecosystem

1.0.0(1mo ago)055MITPHPPHP ^8.4CI passing

Since Jun 16Pushed 1mo agoCompare

[ Source](https://github.com/MeritumIO/migrations)[ Packagist](https://packagist.org/packages/meritum/migrations)[ RSS](/packages/meritum-migrations/feed)WikiDiscussions main Synced 2w ago

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

meritum/migrations
==================

[](#meritummigrations)

Schema migration runner with a CLI interface for the Meritum ecosystem.

Requirements
------------

[](#requirements)

- PHP 8.4+
- `georgeff/kernel` ^1.6
- `georgeff/database` ^1.0
- `georgeff/schema` ^1.1
- `meritum/cli` ^1.0

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

[](#installation)

```
composer require meritum/migrations
```

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

[](#configuration)

All configuration is provided via environment variables. Source them before invoking `strata` or set them in your deployment environment.

VariableDefaultDescription`DB_DRIVER``pgsql`Database driver — `pgsql`, `mysql`, or `sqlite``DB_HOST``localhost`Database host`DB_PORT``5432`Database port`DB_DATABASE`*(empty)*Database name`DB_USERNAME`*(empty)*Database username`DB_PASSWORD`*(empty)*Database password`DB_PGSQL_SCHEMA``public`PostgreSQL schema`DB_PGSQL_SSL_MODE``prefer`PostgreSQL SSL mode`DB_MYSQL_CHARSET``utf8mb4`MySQL charset`DB_MIGRATIONS_TABLE``migrations`Table used to track ran migrations`DB_MIGRATIONS_PATH``./migrations`Directory where migration files are stored`APP_ENV``production`Application environment — affects production guards`APP_DEBUG``false`Enable debug modeThe `DB_MIGRATIONS_PATH` defaults to a `migrations/` directory in whichever directory `strata` is invoked from. Running `strata` from the project root gives `./migrations` without any additional configuration.

Commands
--------

[](#commands)

### `migration:install`

[](#migrationinstall)

Creates the migrations tracking table in the database. Run this once before using any other commands.

```
vendor/bin/strata migration:install
```

Use `--force` or `-f` to run in production environments:

```
vendor/bin/strata migration:install --force
```

Running `migration:run` calls `migration:install` automatically, so explicit installation is optional.

---

### `migration:make`

[](#migrationmake)

Generates a new migration file in the configured migrations directory. The filename is prefixed with a timestamp automatically.

```
vendor/bin/strata migration:make
```

To generate a **create table** migration with a pre-filled stub:

```
vendor/bin/strata migration:make create_users_table --create-table=users
```

To generate an **alter table** migration:

```
vendor/bin/strata migration:make add_email_to_users --alter-table=users
```

Omitting `--create-table` and `--alter-table` generates a blank migration. `--create-table` and `--alter-table` are mutually exclusive.

---

### `migration:run`

[](#migrationrun)

Runs all pending migrations in chronological order. Migrations that have already run are skipped. All pending migrations are grouped into a single batch.

```
vendor/bin/strata migration:run
```

Use `--force` or `-f` to run in production:

```
vendor/bin/strata migration:run --force
```

---

### `migration:rollback`

[](#migrationrollback)

Rolls back all migrations in the last batch by calling their `down()` methods in reverse order.

```
vendor/bin/strata migration:rollback
```

Use `--force` or `-f` to run in production:

```
vendor/bin/strata migration:rollback --force
```

---

### `migration:status`

[](#migrationstatus)

Displays a table of all known migrations with their batch number and timestamp. Pending migrations appear with empty batch and timestamp columns.

```
vendor/bin/strata migration:status
```

```
 -------------------------------------------- ------- ---------------------
  Migration                                    Batch   Migrated At
 -------------------------------------------- ------- ---------------------
  2026_06_01_000000_create_users_table.php     1       2026-06-01 10:00:00
  2026_06_10_000000_create_posts_table.php     2       2026-06-10 14:30:00
  2026_06_15_000000_add_email_to_users.php
 -------------------------------------------- ------- ---------------------

```

Writing migrations
------------------

[](#writing-migrations)

Migration files must return an anonymous class implementing `MigrationInterface`. The `up()` method applies the change; `down()` reverses it.

```
