All Projects → odan → Phinx Migrations Generator

odan / Phinx Migrations Generator

Licence: mit
A Migration Code Generator for Phinx

Projects that are alternatives of or similar to Phinx Migrations Generator

Pg chameleon
MySQL to PostgreSQL replica system
Stars: ✭ 274 (+53.93%)
Mutual labels:  database-migrations, mysql
Liquibase
Main Liquibase Source
Stars: ✭ 2,910 (+1534.83%)
Mutual labels:  database-migrations, mysql
Aerich
A database migrations tool for TortoiseORM, ready to production.
Stars: ✭ 240 (+34.83%)
Mutual labels:  database-migrations, mysql
Shmig
Database migration tool written in BASH.
Stars: ✭ 408 (+129.21%)
Mutual labels:  database-migrations, mysql
Ladder2
A PHP database migration tool for MySQL
Stars: ✭ 7 (-96.07%)
Mutual labels:  database-migrations, mysql
Goose
A database migration tool. Supports SQL migrations and Go functions.
Stars: ✭ 2,112 (+1086.52%)
Mutual labels:  mysql, database-migrations
Dbmate
🚀 A lightweight, framework-agnostic database migration tool.
Stars: ✭ 2,228 (+1151.69%)
Mutual labels:  database-migrations, mysql
Yuniql
Free and open source schema versioning and database migration made natively with .NET Core.
Stars: ✭ 156 (-12.36%)
Mutual labels:  database-migrations, mysql
Hibernate Reactive
A reactive API for Hibernate ORM, supporting non-blocking database drivers and a reactive style of interaction with the database.
Stars: ✭ 167 (-6.18%)
Mutual labels:  mysql
Scalable Wordpress Deployment On Kubernetes
This code showcases the full power of Kubernetes clusters and shows how can we deploy the world's most popular website framework on top of world's most popular container orchestration platform.
Stars: ✭ 173 (-2.81%)
Mutual labels:  mysql
1backend
Run your web apps easily with a complete platform that you can install on any server. Build composable microservices and lambdas.
Stars: ✭ 2,024 (+1037.08%)
Mutual labels:  mysql
Linq2db
Linq to database provider.
Stars: ✭ 2,211 (+1142.13%)
Mutual labels:  mysql
Space Cloud
Open source Firebase + Heroku to develop, scale and secure serverless apps on Kubernetes
Stars: ✭ 3,323 (+1766.85%)
Mutual labels:  mysql
Lzhpo Shiro
美观、漂亮,我抽离出来的,拿来即用的简单后台管理系统!
Stars: ✭ 170 (-4.49%)
Mutual labels:  mysql
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (-1.12%)
Mutual labels:  mysql
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (-5.06%)
Mutual labels:  mysql
Easyadmin
简易的java后台管理框架,基于SpringBoot+FreeMark+ace admin+mysql
Stars: ✭ 169 (-5.06%)
Mutual labels:  mysql
Databases
Async database support for Python. 🗄
Stars: ✭ 2,602 (+1361.8%)
Mutual labels:  mysql
Nanodbc
A small C++ wrapper for the native C ODBC API | Requires C++14 since v2.12
Stars: ✭ 175 (-1.69%)
Mutual labels:  mysql
Docker Compose Development
Clone and `bin/dev up`. Quickly start of developing locally with Nginx, PHP, Blackfire, Percona, Mailhog and Redis. Out of the box support for Magento2 Developer Box
Stars: ✭ 171 (-3.93%)
Mutual labels:  mysql

Phinx migrations generator

Generates Phinx migrations by comparing your current database with your schema information.

Latest Version on Packagist Software License Build Status Code Coverage Quality Score Total Downloads

Requirements

  • PHP 7.2+ or 8.0+

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

Parameter Values Default Description
--name string The class name.
--overwrite bool Overwrite schema.php file.
--path string (from phinx) Specify the path in which to generate this migration.
--environment or -e string (from phinx) The target environment.
--configuration or -c string (from phinx) The configuration file e.g. config/phinx.php

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

Parameter Values Default Description
foreign_keys bool false Enable or disable foreign key migrations.
default_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.
generate_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.
mark_generated_migration bool true Enable or disable marking the migration as applied after creation.
migration_base_class string \Phinx\Migration\AbstractMigration Sets up base class of created migration.
schema_file string %%PHINX_CONFIG_DIR%%/db/ migrations/schema.php Specifies the location for saving the schema file.

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=utf8', 'root', '',
    array(
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_PERSISTENT => false,
        PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8 COLLATE utf8_unicode_ci',
    )
);

// Get migration path for phinx classes
$migrationPath = __DIR__ . '/resources/migrations';

return [
    'paths' => [
        'migrations' => $migrationPath,
    ],
    'foreign_keys' => false,
    'default_migration_prefix' => 'db_change_',
    'mark_generated_migration' => true,
    'migration_base_class' => \Phinx\Migration\AbstractMigration::class,
    '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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].