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

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

roolith/migration
=================

php simple migration

1.2.0(5mo ago)09MITPHPPHP &gt;=8.0

Since Oct 18Pushed 5mo agoCompare

[ Source](https://github.com/im4aLL/roolith-migration)[ Packagist](https://packagist.org/packages/roolith/migration)[ RSS](/packages/roolith-migration/feed)WikiDiscussions main Synced 1mo ago

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

roolith-migration
=================

[](#roolith-migration)

Simple migration and seeding tool for PHP applications.

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

[](#installation)

You can install roolith-migration using Composer:

```
composer require roolith/migration
```

Usage
-----

[](#usage)

Create a PHP file `migration.php` and add the following code:

```
use Roolith\Migration\Migration;

require __DIR__ . "/../vendor/autoload.php";

$migration = new Migration();
$migration
    ->settings([
        "folder" => __DIR__ . "/migrations",
        "database" => [
            "host" => "localhost",
            "name" => "db_name",
            "user" => "user",
            "pass" => "pass",
        ],
    ])
    ->run($argv);
```

Command
-------

[](#command)

Assuming your filename is `migration.php`, you can run the migration command as follows:

```
php migration.php migration:create migration_name
php migration.php migration:run # it will run all pending migrations
php migration.php migration:run migration_name
php migration.php migration:rollback migration_name
php migration.php migration:status
```

For seeding data, you can use the following command:

```
php migration.php seeder:create seed_name
php migration.php seeder:run # it will run all pending seeds
php migration.php seeder:run seed_name
```

Notes
-----

[](#notes)

- it will create migrations table if not exists
- it will create migrations folder if not exists
- You can change the name of the folder by passing settings

Example of migration file
-------------------------

[](#example-of-migration-file)

```
php migration.php migration:create create_users_table
```

```
