{"id":18950953,"url":"https://github.com/alwex/php-database-migration","last_synced_at":"2025-04-07T06:09:56.487Z","repository":{"id":535566,"uuid":"2619369","full_name":"alwex/php-database-migration","owner":"alwex","description":"Database Migration tool for PHP","archived":false,"fork":false,"pushed_at":"2021-08-30T23:17:06.000Z","size":167,"stargazers_count":85,"open_issues_count":9,"forks_count":33,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-31T05:03:38.894Z","etag":null,"topics":["database-migrations","php","php-database-migration"],"latest_commit_sha":null,"homepage":"https://alwex.github.io/php-database-migration/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alwex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-10-21T09:47:45.000Z","updated_at":"2023-11-12T12:11:29.000Z","dependencies_parsed_at":"2022-08-06T09:15:42.910Z","dependency_job_id":null,"html_url":"https://github.com/alwex/php-database-migration","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwex%2Fphp-database-migration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwex%2Fphp-database-migration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwex%2Fphp-database-migration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwex%2Fphp-database-migration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alwex","download_url":"https://codeload.github.com/alwex/php-database-migration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601448,"owners_count":20964864,"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","php","php-database-migration"],"created_at":"2024-11-08T13:25:29.115Z","updated_at":"2025-04-07T06:09:56.465Z","avatar_url":"https://github.com/alwex.png","language":"PHP","readme":"PhpDbMigration - full PHP database migration tool\n=================================================\n\n[![Build Status](https://travis-ci.org/alwex/php-database-migration.svg?branch=master)](https://travis-ci.org/alwex/php-database-migration)\n[![Packagist](https://img.shields.io/packagist/dt/php-database-migration/php-database-migration.svg?maxAge=2592000)]()\n[![Version](http://img.shields.io/packagist/v/php-database-migration/php-database-migration.svg?style=flat)](https://packagist.org/packages/php-database-migration/php-database-migration)\n\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/5363e9e0-123a-4a8e-ad64-cb019e63bbba/big.png)](https://insight.sensiolabs.com/projects/5363e9e0-123a-4a8e-ad64-cb019e63bbba)\n\nThis is a full standalone PHP tool based on [Symfony Console](http://symfony.com/doc/current/components/console)\nand inspired by the Rails database migration tool and MyBatis. It merges the functionality of the two tools and\nhas been designed to be as flexible as possible.\n\nUsage\n-----\n```\n$ ./bin/migrate\nConsole Tool\n\nUsage:\n  command [options] [arguments]\n\nOptions:\n  -h, --help            Display this help message\n  -q, --quiet           Do not output any message\n  -V, --version         Display this application version\n      --ansi            Force ANSI output\n      --no-ansi         Disable ANSI output\n  -n, --no-interaction  Do not ask any interactive question\n  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\n\nAvailable commands:\n  help            Displays help for a command\n  list            Lists commands\n migrate\n  migrate:addenv  Initialise an environment to work with php db migrate\n  migrate:create  Create a SQL migration\n  migrate:down    Rollback all waiting migration down to [to] option if precised\n  migrate:init    Create the changelog table on your environment database\n  migrate:status  Display the current status of the specified environment\n  migrate:up      Execute all waiting migration up to [to] option if precised\n```\n\nInstalling it to your project\n-----------------------------\nJust add it to your composer.json (don't forget to specify your bin directory)\nWarning, all migrate commands must be executed on your root folder like `bin/migrate migrate:command...`\n\n    {\n        \"name\": \"jdoe/testproject\",\n        \"authors\": [\n            {\n                \"name\": \"Jhon DOE\",\n                \"email\": \"jdoe@gmail.com\"\n            }\n        ],\n        \"require\": {\n            \"php-database-migration/php-database-migration\" :\"3.6.*\"\n        },\n        \"config\": {\n            \"bin-dir\": \"bin\"\n        }\n    }\n\n\nAdding an environment\n---------------------\nThe first thing to do before playing with SQL migrations is to add an environment, let's add the dev one.\n\n```\n$ ./bin/migrate migrate:addenv\n```\n\nYou will be prompted to answer a series of questions about your environment, and then a config file will be saved\nin `./.php-database-migration/environments/[env].yml`.\n\nInitialization\n--------------\nOnce the environment is added, you have to initialize it. This verifies that the database connection works, and\ncreates a new database table for tracking the current database changes:\n\n```\n$ ./bin/migrate migrate:init [env]\n```\n\nCreate a migration\n------------------\nIt is time to create our first migration file.\n\n```\n$ ./bin/migrate migrate:create\n```\n\nMigrations file are like this\n\n    -- // add table users\n    -- Migration SQL that makes the change goes here.\n    create table users (id integer, name text);\n    -- @UNDO\n    -- SQL to undo the change goes here.\n    drop table users;\n\nList migrations\n------------------\nView all available migrations and their status.\n\n```\n$ ./bin/migrate migrate:status [env]\n+----------------+---------+------------------+--------------------+\n| id             | version | applied at       | description        |\n+----------------+---------+------------------+--------------------+\n| 14679010838251 |         |                  | create table users |\n+----------------+---------+------------------+--------------------+\n```\n\nUp and down\n-----------\nYou can now up all the pending migrations. If you decide to down a migration, the last one will be downed alone to\nprevent mistakes. You will be asked to confirm the downgrade of your database before running the real SQL script.\n\n```\n$ ./bin/migrate migrate:up [env]\n```\n\nYou can mark migrations as applied without executing SQL (e.g. if you switched from another migration system)\n\n```\n$ ./bin/migrate migrate:up [env] --changelog-only\n```\n\nFor development purposes, it is also possible to up a single migration without taking care of the other ones:\n\n```\n$ ./bin/migrate migrate:up [env] --only=[migrationid]\n```\n\nor migrate to specific migration (it will run all migrations, including the specified migration)\n\n```\n$ ./bin/migrate migrate:up [env] --to=[migrationid]\n```\n\nSame thing for down:\n\n```\n$ ./bin/migrate migrate:down [env] --only=[migrationid]\n```\n\nor\n\n\n```\n$ ./bin/migrate migrate:down [env] --to=[migrationid]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwex%2Fphp-database-migration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falwex%2Fphp-database-migration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwex%2Fphp-database-migration/lists"}