{"id":13593919,"url":"https://github.com/odan/phinx-migrations-generator","last_synced_at":"2025-05-16T05:03:44.020Z","repository":{"id":9675251,"uuid":"61276581","full_name":"odan/phinx-migrations-generator","owner":"odan","description":"A Migration Code Generator for Phinx","archived":false,"fork":false,"pushed_at":"2024-07-12T15:59:23.000Z","size":884,"stargazers_count":233,"open_issues_count":0,"forks_count":47,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-08T14:12:33.114Z","etag":null,"topics":["database-migrations","mysql","phinx","phinx-migrations","php"],"latest_commit_sha":null,"homepage":"https://odan.github.io/phinx-migrations-generator/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/odan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-16T08:40:31.000Z","updated_at":"2025-03-30T13:53:03.000Z","dependencies_parsed_at":"2024-11-28T20:04:10.434Z","dependency_job_id":"56707c85-63c6-4511-af99-37f462ae339e","html_url":"https://github.com/odan/phinx-migrations-generator","commit_stats":{"total_commits":470,"total_committers":23,"mean_commits":"20.434782608695652","dds":0.4765957446808511,"last_synced_commit":"d75e4ddd20e519621cfb753b063abdde1e181af4"},"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Fphinx-migrations-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Fphinx-migrations-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Fphinx-migrations-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Fphinx-migrations-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odan","download_url":"https://codeload.github.com/odan/phinx-migrations-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471062,"owners_count":22076585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-migrations","mysql","phinx","phinx-migrations","php"],"created_at":"2024-08-01T16:01:26.297Z","updated_at":"2025-05-16T05:03:43.982Z","avatar_url":"https://github.com/odan.png","language":"PHP","readme":"# Phinx migrations generator\n\nGenerates [Phinx](https://phinx.org/) migrations by comparing your current database with your schema information.\n\n[![Latest Version on Packagist](https://img.shields.io/github/release/odan/phinx-migrations-generator.svg)](https://packagist.org/packages/odan/phinx-migrations-generator)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md)\n[![Build Status](https://github.com/odan/phinx-migrations-generator/workflows/build/badge.svg)](https://github.com/odan/phinx-migrations-generator/actions)\n[![Code Coverage](https://scrutinizer-ci.com/g/odan/phinx-migrations-generator/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/odan/phinx-migrations-generator/?branch=master)\n[![Quality Score](https://scrutinizer-ci.com/g/odan/phinx-migrations-generator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/odan/phinx-migrations-generator/?branch=master)\n[![Total Downloads](https://img.shields.io/packagist/dt/odan/phinx-migrations-generator.svg)](https://packagist.org/packages/odan/phinx-migrations-generator/stats)\n\n## Requirements\n\n* PHP 8.1, 8.2\n\n## Features\n\n* Framework independent\n* DBMS: MySQL 5.7+, MySQL 8, MariaDB (partially supported)\n* Initial schema \n* Schema difference\n* Database: character set, collation\n* Tables: create, update, remove, engine, comment, character set, collation\n* Columns: create, update, remove\n* Indexes: create, remove\n* Foreign keys: create, remove, constraint name\n\n## Install\n\nVia Composer\n\n```\ncomposer require odan/phinx-migrations-generator --dev\n```\n\n## Usage\n\n### Generating migrations\n\nThe first run generates an initial schema and a migration class.\nThe file `schema.php` contains the previous database schema and is compared with the current schema.\nBased on the difference, a Phinx migration class is generated.\n\n```\nvendor/bin/phinx-migrations generate\n```\n\nWhen the `generate` command is executed again, only the difference to the last schema is generated.\n\n## Parameters\n\nParameter | Values | Default | Description\n--- | --- | --- | ---\n--name | string | | The class name.\n--overwrite | bool |  | Overwrite schema.php file.\n--path \u003cpath\u003e | string | (from phinx) | Specify the path in which to generate this migration.\n--environment or -e | string | (from phinx) | The target environment.\n--configuration or -c | string | (from phinx) | The configuration file e.g. `config/phinx.php`\n\n### Running migrations\n\nThe [Phinx migrate command](http://docs.phinx.org/en/latest/commands.html#the-migrate-command) \nruns all the available migrations.\n\n```\nvendor/bin/phinx migrate\n```\n\n## Configuration\n\nThe phinx-migrations-generator uses the configuration of phinx.\n\n## Migration configuration\n\nParameter | Values | Default | Description\n--- | --- | --- | ---\nforeign_keys | bool | false | Enable or disable foreign key migrations.\ndefault_migration_prefix | string | null | If 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.\ngenerate_migration_name | bool | false | If 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.\nmark_generated_migration | bool | true | Enable or disable marking the migration as applied after creation.\nmigration_base_class | string | `\\Phinx\\Migration\\AbstractMigration` | Sets up base class of created migration.\nschema_file | string | `%%PHINX_CONFIG_DIR%%/db/` `migrations/schema.php` | Specifies the location for saving the schema file.\n\n### Example configuration\n\nFilename: `phinx.php` (in your project root directory)\n\n```php\n\u003c?php\n\n// Framework bootstrap code here\nrequire_once __DIR__ . '/config/bootstrap.php';\n\n// Get PDO object\n$pdo = new PDO(\n    'mysql:host=127.0.0.1;dbname=test;charset=utf8mb4', 'root', '',\n    array(\n        PDO::ATTR_ERRMODE =\u003e PDO::ERRMODE_EXCEPTION,\n        PDO::ATTR_PERSISTENT =\u003e false,\n        PDO::MYSQL_ATTR_INIT_COMMAND =\u003e 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci',\n    )\n);\n\nreturn [\n    'paths' =\u003e [\n        'migrations' =\u003e __DIR__ . '/../resources/migrations',\n    ],\n    'schema_file' =\u003e __DIR__ . '/../resources/schema/schema.php',\n    'foreign_keys' =\u003e false,\n    'default_migration_prefix' =\u003e '',\n    'mark_generated_migration' =\u003e true,\n    'environments' =\u003e [\n        'default_environment' =\u003e 'local',\n        'local' =\u003e [\n            // Database name\n            'name' =\u003e $pdo-\u003equery('select database()')-\u003efetchColumn(),\n            'connection' =\u003e $pdo,\n        ]\n    ]\n];\n```\n\n## Testing\n\n```\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodan%2Fphinx-migrations-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodan%2Fphinx-migrations-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodan%2Fphinx-migrations-generator/lists"}