cycle / migrations
Database migrations, migration scaffolding
Installs: 354 735
Dependents: 29
Suggesters: 4
Security: 0
Stars: 20
Watchers: 5
Forks: 15
Open Issues: 13
Requires
- php: >=8.1
- cycle/database: ^2.7.0
- spiral/core: ^3.0
- spiral/files: ^3.0
- spiral/reactor: ^3.0
- spiral/tokenizer: ^3.0
Requires (Dev)
- buggregator/trap: ^1.11
- mockery/mockery: ^1.5
- phpunit/phpunit: ^9.5
- spiral/code-style: ~2.2.0
- vimeo/psalm: ^5.25
- 4.x-dev
- v4.2.4
- v4.2.3
- v4.2.2
- v4.2.1
- v4.2.0
- v4.1.0
- v4.0.1
- v4.0.0
- 3.x-dev
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.0
- 2.x-dev
- v2.0.0
- 1.x-dev
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-code-style
- dev-new-builder
- dev-feature/spiral-preconition-hints
- dev-pr/primary_to_primary_bigint
This package is auto-updated.
Last update: 2024-10-24 17:39:13 UTC
README
Migrations are a convenient way for you to alter your database in a structured and organized manner. This package adds additional functionality for versioning your database schema and easily deploying changes to it. It is a very easy to use and a powerful tool.
Installation
composer require cycle/migrations ^4.0
Configuration
use Cycle\Migrations; use Cycle\Database; use Cycle\Database\Config; $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, ), ] ])); $config = new Migrations\Config\MigrationConfig([ 'directory' => __DIR__ . '/../migrations/', // where to store migrations 'vendorDirectories' => [ // Where to look for vendor package migrations __DIR__ . '/../vendor/vendorName/packageName/migrations/' ], 'table' => 'migrations' // database table to store migration status 'safe' => true // When set to true no confirmation will be requested on migration run. ]); $migrator = new Migrations\Migrator( $config, $dbal, new Migrations\FileRepository($config) ); // Init migration table $migrator->configure();
Running
while (($migration = $migrator->run()) !== null) { echo 'Migrate ' . $migration->getState()->getName(); }
Generate Migrations
You can automatically generate a set of migration files during schema compilation. In this case, you have the freedom to alter such migrations manually before running them. To achieve that you must install the Schema migrations generator extension.
License:
MIT License (MIT). Please see LICENSE
for more information. Maintained
by Spiral Scout.