https://github.com/cycle/schema-migrations-generator
Migrations generator
https://github.com/cycle/schema-migrations-generator
database-migrations hacktoberfest
Last synced: 9 months ago
JSON representation
Migrations generator
- Host: GitHub
- URL: https://github.com/cycle/schema-migrations-generator
- Owner: cycle
- License: mit
- Created: 2021-08-11T08:04:33.000Z (almost 5 years ago)
- Default Branch: 2.x
- Last Pushed: 2024-12-23T11:28:50.000Z (over 1 year ago)
- Last Synced: 2025-09-23T11:54:47.393Z (9 months ago)
- Topics: database-migrations, hacktoberfest
- Language: PHP
- Size: 118 KB
- Stars: 3
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cycle ORM - Migration Generator
[](https://packagist.org/packages/cycle/schema-migrations-generator)
[](https://github.com/cycle/schema-migrations-generator/actions)
[](https://scrutinizer-ci.com/g/cycle/schema-migrations-generator/?branch=2.x)
[](https://codecov.io/gh/cycle/schema-migrations-generator)
By migration generator package you can automatically generate a set of migration files for Cycle ORM during schema
compilation. In this case, you have the freedom to alter such migrations manually before running them.
## Installation
```bash
composer require cycle/schema-migrations-generator
```
## Configuration
```php
use Cycle\Migrations;
use Cycle\Schema\Registry;
use Cycle\Schema\Definition\Entity;
use Cycle\Database;
use Cycle\Database\Config;
use Cycle\Schema\Generator\Migrations\GenerateMigrations;
$dbal = new Database\DatabaseManager(new Config\DatabaseConfig([
'default' => 'default',
'databases' => [
'default' => [
'connection' => 'sqlite'
]
],
'connections' => [
'sqlite' => new Config\SQLiteDriverConfig(
connection: new Config\SQLite\MemoryConnectionConfig(),
queryCache: true,
),
]
]));
$migrator = new Migrations\Migrator(
$config,
$dbal,
new Migrations\FileRepository($config)
);
$registry = new Registry($dbal);
$registry->register(....);
$generator = new GenerateMigrations(
$migrator->getRepository(),
$migrator->getConfig()
);
```
## Running
Migration generator creates set of migrations needed to sync database schema with desired state. Each database will
receive its own migration.
```php
$generator->run($registry);
```
## License:
The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. Maintained
by [Spiral Scout](https://spiralscout.com).