PHPackages                             hypocenter/phinx-migrations-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. hypocenter/phinx-migrations-generator

ActiveLibrary[Database &amp; ORM](/categories/database)

hypocenter/phinx-migrations-generator
=====================================

Migration generator for Phinx

5.5.0(5y ago)09MITPHPPHP ^7.2 || ^8.0

Since Jul 9Pushed 5y agoCompare

[ Source](https://github.com/tuoz/phinx-migrations-generator)[ Packagist](https://packagist.org/packages/hypocenter/phinx-migrations-generator)[ Docs](https://github.com/hypocenter/phinx-migrations-generator)[ RSS](/packages/hypocenter-phinx-migrations-generator/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (9)Versions (64)Used By (0)

Phinx migrations generator
==========================

[](#phinx-migrations-generator)

Generates [Phinx](https://phinx.org/) migrations by comparing your current database with your schema information.

[![Latest Version on Packagist](https://camo.githubusercontent.com/b11559de1a21146aa7a67fc53110c44faac59d569bb0a164cac4d0da5b703fd9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6f64616e2f7068696e782d6d6967726174696f6e732d67656e657261746f722e737667)](https://packagist.org/packages/odan/phinx-migrations-generator)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)[![Build Status](https://github.com/odan/phinx-migrations-generator/workflows/build/badge.svg)](https://github.com/odan/phinx-migrations-generator/actions)[![Code Coverage](https://camo.githubusercontent.com/0824b5d413858e5bf7499ab5d8125b7ec7db9fcac0ef05a5d64e5e403fefcd4b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f64616e2f7068696e782d6d6967726174696f6e732d67656e657261746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/odan/phinx-migrations-generator/?branch=master)[![Quality Score](https://camo.githubusercontent.com/0f66066dc51ab69d5eb39ce4d5b9f96d6a9911f8fdee9bfe56e0ce65e03d4eb2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f64616e2f7068696e782d6d6967726174696f6e732d67656e657261746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/odan/phinx-migrations-generator/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/bfdfb084951184cced225d3e340e7dda9ff19961916af4b766179023da7ddd99/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f64616e2f7068696e782d6d6967726174696f6e732d67656e657261746f722e737667)](https://packagist.org/packages/odan/phinx-migrations-generator/stats)

Requirements
------------

[](#requirements)

- PHP 7.2+ or 8.0+

Features
--------

[](#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
-------

[](#install)

Via Composer

```
$ composer require odan/phinx-migrations-generator --dev

```

Usage
-----

[](#usage)

### Generating migrations

[](#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
----------

[](#parameters)

ParameterValuesDefaultDescription--namestringThe class name.--overwriteboolOverwrite schema.php file.--path string(from phinx)Specify the path in which to generate this migration.--environment or -estring(from phinx)The target environment.--configuration or -cstring(from phinx)The configuration file e.g. `config/phinx.php`### Running migrations

[](#running-migrations)

The [Phinx migrate command](http://docs.phinx.org/en/latest/commands.html#the-migrate-command)runs all the available migrations.

```
$ vendor/bin/phinx migrate

```

Configuration
-------------

[](#configuration)

The phinx-migrations-generator uses the configuration of phinx.

Migration configuration
-----------------------

[](#migration-configuration)

ParameterValuesDefaultDescriptionforeign\_keysboolfalseEnable or disable foreign key migrations.default\_migration\_prefixstringnullIf specified, in the absence of the name parameter, the default migration name will be offered with this prefix and a random hash at the end.generate\_migration\_nameboolfalseIf enabled, a random migration name will be generated. The user will not be prompted for a migration name anymore. The parameter `default_migration_prefix` must be specified. The `--name` parameter can overwrite this setting.mark\_generated\_migrationbooltrueEnable or disable marking the migration as applied after creation.migration\_base\_classstring`\Phinx\Migration\AbstractMigration`Sets up base class of created migration.schema\_filestring`%%PHINX_CONFIG_DIR%%/db/` `migrations/schema.php`Specifies the location for saving the schema file.### Example configuration

[](#example-configuration)

Filename: `phinx.php` (in your project root directory)

```
