cycle / schema-migrations-generator
Cycle ORM 迁移生成
2.2.0
2023-11-02 09:24 UTC
Requires
- php: >=8.1
- cycle/database: ^2.4.1
- cycle/migrations: ^4.2
- cycle/schema-builder: ^2.0
Requires (Dev)
- cycle/annotated: ^3.0
- cycle/orm: ^2.0
- phpunit/phpunit: ^9.5
- spiral/debug: ^3.0
- spiral/framework: ^3.0
README
通过迁移生成器包,您可以在模式编译期间自动生成一组迁移文件用于 Cycle ORM。在这种情况下,您可以在运行之前手动修改这些迁移。
安装
composer require cycle/schema-migrations-generator
配置
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() );
运行
迁移生成器创建一组所需的迁移,以同步数据库模式与期望的状态。每个数据库将接收自己的迁移。
$generator->run($registry);
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅LICENSE
。由 Spiral Scout 维护。