{"id":21467416,"url":"https://github.com/elusivecodes/fyremigration","last_synced_at":"2025-07-15T05:31:31.231Z","repository":{"id":62551363,"uuid":"502587266","full_name":"elusivecodes/FyreMigration","owner":"elusivecodes","description":"FyreMigration is a free, open-source migration library for PHP.","archived":false,"fork":false,"pushed_at":"2024-11-08T12:37:28.000Z","size":157,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-08T13:07:20.848Z","etag":null,"topics":["migration","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elusivecodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-12T10:44:06.000Z","updated_at":"2024-11-08T12:37:15.000Z","dependencies_parsed_at":"2024-08-14T06:29:56.455Z","dependency_job_id":null,"html_url":"https://github.com/elusivecodes/FyreMigration","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreMigration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreMigration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreMigration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreMigration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FyreMigration/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226017479,"owners_count":17560521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["migration","php"],"created_at":"2024-11-23T08:17:55.954Z","updated_at":"2025-07-15T05:31:31.159Z","avatar_url":"https://github.com/elusivecodes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FyreMigration\r\n\r\n**FyreMigration** is a free, open-source migration library for *PHP*.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Basic Usage](#basic-usage)\r\n- [Methods](#methods)\r\n- [Migrations](#migrations)\r\n- [Migration Histories](#migration-histories)\r\n- [Commands](#commands)\r\n    - [Migrate](#migrate)\r\n    - [Rollback](#rollback)\r\n\r\n\r\n\r\n## Installation\r\n\r\n**Using Composer**\r\n\r\n```\r\ncomposer require fyre/migration\r\n```\r\n\r\nIn PHP:\r\n\r\n```php\r\nuse Fyre\\Migration\\MigrationRunner;\r\n```\r\n\r\n\r\n## Basic Usage\r\n\r\n- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n- `$loader` is a [*Loader*](https://github.com/elusivecodes/FyreLoader).\r\n- `$connectionManager` is a [*ConnectionManager*](https://github.com/elusivecodes/FyreDB).\r\n- `$forgeRegistry` is a [*ForgeRegistry*](https://github.com/elusivecodes/FyreForge).\r\n\r\n```php\r\n$runner = new MigrationRunner($container, $loader, $connectionManager, $forgeRegistry);\r\n```\r\n\r\n**Autoloading**\r\n\r\nIt is recommended to bind the *MigrationRunner* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.\r\n\r\n```php\r\n$container-\u003esingleton(MigrationRunner::class);\r\n```\r\n\r\nAny dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n```php\r\n$runner = $container-\u003euse(MigrationRunner::class);\r\n```\r\n\r\n\r\n## Methods\r\n\r\n**Add Namespace**\r\n\r\nAdd a namespace for loading migrations.\r\n\r\n- `$namespace` is a string representing the namespace.\r\n\r\n```php\r\n$runner-\u003eaddNamespace($namespace);\r\n```\r\n\r\n**Clear**\r\n\r\nClear all namespaces and migrations.\r\n\r\n```php\r\n$runner-\u003eclear();\r\n```\r\n\r\n**Get Connection**\r\n\r\nGet the [*Connection*](https://github.com/elusivecodes/FyreDB#connections).\r\n\r\n```php\r\n$connection = $runner-\u003egetConnection();\r\n```\r\n\r\n**Get Forge**\r\n\r\nGet the [*Forge*](https://github.com/elusivecodes/FyreForge#forges).\r\n\r\n```php\r\n$forge = $runner-\u003egetForge();\r\n```\r\n\r\n**Get History**\r\n\r\nGet the [*MigrationHistory*](#migration-histories).\r\n\r\n```php\r\n$history = $runner-\u003egetHistory();\r\n```\r\n\r\n**Get Migrations**\r\n\r\nGet all migrations.\r\n\r\n```php\r\n$migrations = $runner-\u003egetMigrations();\r\n```\r\n\r\n**Get Namespaces**\r\n\r\nGet the namespaces.\r\n\r\n```php\r\n$namespaces = $runner-\u003egetNamespaces();\r\n```\r\n\r\n**Has Namespace**\r\n\r\nDetermine whether a namespace exists.\r\n\r\n- `$namespace` is a string representing the namespace.\r\n\r\n```php\r\n$hasNamespace = $php-\u003ehasNamespace($namespace);\r\n```\r\n\r\n**Migrate**\r\n\r\nMigrate to the latest version.\r\n\r\n```php\r\n$runner-\u003emigrate($latestVersion);\r\n```\r\n\r\n**Rollback**\r\n\r\nRollback to a previous version.\r\n\r\n- `$batches` is a number representing the number of batches to rollback, and will default to *1*.\r\n- `$steps` is a number representing the number of steps to rollback, and will default to *null*.\r\n\r\n```php\r\n$runner-\u003erollback($batches, $steps);\r\n```\r\n\r\n**Set Connection**\r\n\r\nSet the [*Connection*](https://github.com/elusivecodes/FyreDB#connections).\r\n\r\n- `$connection` is the [*Connection*](https://github.com/elusivecodes/FyreDB#connections).\r\n\r\n```php\r\n$runner-\u003esetConnection($connection);\r\n```\r\n\r\n**Remove Namespace**\r\n\r\nRemove a namespace.\r\n\r\n- `$namespace` is a string representing the namespace.\r\n\r\n```php\r\n$runner-\u003eremoveNamespace($namespace);\r\n```\r\n\r\n\r\n## Migrations\r\n\r\nMigrations can be created by extending the `\\Fyre\\Migration\\Migration` class, prefixing the class name with \"*Migration_*\".\r\n\r\nTo allow discovery of the migration, add the the namespace to the *MigrationRunner*.\r\n\r\n**Down**\r\n\r\nPerform a \"down\" migration.\r\n\r\n```php\r\n$migration-\u003edown();\r\n```\r\n\r\n**Up**\r\n\r\nPerform an \"up\" migration.\r\n\r\n```php\r\n$migration-\u003eup();\r\n```\r\n\r\n\r\n## Migration Histories\r\n\r\n**Add**\r\n\r\nAdd a migration version to the history.\r\n\r\n- `$name` is a string representing the migration name.\r\n- `$batch` is a number representing the batch number.\r\n\r\n```php\r\n$history-\u003eadd($name, $batch);\r\n```\r\n\r\n**All**\r\n\r\nGet the migration history.\r\n\r\n```php\r\n$all = $history-\u003eall();\r\n```\r\n\r\n**Delete**\r\n\r\nDelete a migration from the history.\r\n\r\n- `$name` is a string representing the migration name.\r\n\r\n```php\r\n$history-\u003edelete($name);\r\n```\r\n\r\n**Get Next Batch**\r\n\r\nGet the next batch number.\r\n\r\n```php\r\n$batch = $history-\u003egetNextBatchNumber();\r\n```\r\n\r\n\r\n## Commands\r\n\r\n### Migrate\r\n\r\nPerform database migrations.\r\n\r\n- `--db` is the [*ConnectionManager*](https://github.com/elusivecodes/FyreDB) config key, and will default to `ConnectionManager::DEFAULT`.\r\n\r\n```php\r\n$commandRunner-\u003erun('db:migrate', ['--db', 'default']);\r\n```\r\n\r\n### Rollback\r\n\r\nPerform database rollbacks.\r\n\r\n- `--db` is the [*ConnectionManager*](https://github.com/elusivecodes/FyreDB) config key, and will default to `ConnectionManager::DEFAULT`.\r\n- `--batches` is the number of batches to rollback, and will default to *1*.\r\n- `--steps` is the number of steps to rollback, and will default to *null*.\r\n\r\n```php\r\n$commandRunner-\u003erun('db:rollback', ['--db', 'default', '--batches', '1', '--steps', 1]);\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyremigration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffyremigration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyremigration/lists"}