odan / phinx-migrations-generator
Migration generator for Phinx
Installs: 629 063
Dependents: 22
Suggesters: 0
Security: 0
Stars: 231
Watchers: 18
Forks: 46
Open Issues: 0
Requires
- php: ~8.1 || ~8.2
- ext-json: *
- ext-pdo: *
- riimu/kit-phpencoder: ^2.4
- robmorgan/phinx: ^0.15.2 | ^0.16
Requires (Dev)
- dev-master
- 6.2.1
- 6.2.0
- 6.1.1
- 6.1.0
- 6.0.1
- 6.0.0
- 5.7.1
- 5.7.0
- 5.6.0
- 5.5.0
- 5.4.3
- 5.4.2
- 5.4.1
- 5.4.0
- 5.3.2.x-dev
- 5.3.2
- 5.3.1
- 5.3.0
- 5.2.0
- 5.1.2
- 5.1.1
- 5.1.0
- 5.0.0
- 4.6.1
- 4.6.0
- 4.5.0
- 4.4.1
- 4.4.0
- 4.3.0
- 4.2.0
- 4.1.0
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.1.0
- 3.0.1
- 3.0.0
- 2.7.0
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.4
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.0
- 1.2.0
- 1.1.0
- 1.0.0
- 0.7.0
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.1
- 0.5.0
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.0
- 0.0.2
- 0.0.1
- dev-dependabot/add-v2-config-file
This package is auto-updated.
Last update: 2024-11-12 16:37:38 UTC
README
Generates Phinx migrations by comparing your current database with your schema information.
Requirements
- PHP 8.1, 8.2
Features
- Framework independent
- DBMS: MySQL 5.7+, MySQL 8, MariaDB (partially supported)
- Initial schema
- Schema difference
- Database: character set, collation
- Tables: create, update, remove, engine, comment, character set, collation
- Columns: create, update, remove
- Indexes: create, remove
- Foreign keys: create, remove, constraint name
Install
Via Composer
composer require odan/phinx-migrations-generator --dev
Usage
Generating migrations
The first run generates an initial schema and a migration class.
The file schema.php
contains the previous database schema and is compared with the current schema.
Based on the difference, a Phinx migration class is generated.
vendor/bin/phinx-migrations generate
When the generate
command is executed again, only the difference to the last schema is generated.
Parameters
Running migrations
The Phinx migrate command runs all the available migrations.
vendor/bin/phinx migrate
Configuration
The phinx-migrations-generator uses the configuration of phinx.
Migration configuration
Example configuration
Filename: phinx.php
(in your project root directory)
<?php // Framework bootstrap code here require_once __DIR__ . '/config/bootstrap.php'; // Get PDO object $pdo = new PDO( 'mysql:host=127.0.0.1;dbname=test;charset=utf8mb4', 'root', '', array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_PERSISTENT => false, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci', ) ); return [ 'paths' => [ 'migrations' => __DIR__ . '/../resources/migrations', ], 'schema_file' => __DIR__ . '/../resources/schema/schema.php', 'foreign_keys' => false, 'default_migration_prefix' => '', 'mark_generated_migration' => true, 'environments' => [ 'default_environment' => 'local', 'local' => [ // Database name 'name' => $pdo->query('select database()')->fetchColumn(), 'connection' => $pdo, ] ] ];
Testing
composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
License
The MIT License (MIT). Please see License File for more information.