{"id":13824901,"url":"https://github.com/kohkimakimoto/phpmigrate","last_synced_at":"2025-09-19T17:41:16.975Z","repository":{"id":7708990,"uuid":"9073904","full_name":"kohkimakimoto/phpmigrate","owner":"kohkimakimoto","description":"PHPMigrate is a minimum database migration tool for MySQL.","archived":false,"fork":false,"pushed_at":"2013-06-19T02:42:37.000Z","size":243,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T02:41:16.558Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/kohkimakimoto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-28T09:30:45.000Z","updated_at":"2019-03-22T13:03:06.000Z","dependencies_parsed_at":"2022-09-03T09:20:30.229Z","dependency_job_id":null,"html_url":"https://github.com/kohkimakimoto/phpmigrate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kohkimakimoto/phpmigrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kohkimakimoto%2Fphpmigrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kohkimakimoto%2Fphpmigrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kohkimakimoto%2Fphpmigrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kohkimakimoto%2Fphpmigrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kohkimakimoto","download_url":"https://codeload.github.com/kohkimakimoto/phpmigrate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kohkimakimoto%2Fphpmigrate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275977556,"owners_count":25563405,"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","status":"online","status_checked_at":"2025-09-19T02:00:09.700Z","response_time":108,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-08-04T09:01:11.412Z","updated_at":"2025-09-19T17:41:16.908Z","avatar_url":"https://github.com/kohkimakimoto.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# PHPMigrate\n\nPHPMigrate is a minimum database migration tool for MySQL.\n\nUses plain SQL to change schema. And runs some PHP codes post and previous executing SQL.\n\n**This software was restructured to [LibMigration](https://github.com/kohkimakimoto/lib-migration) to use easily in other PHP products.**\n\n## Requrement\n\n* PHP5.x or later (Probably).\n\n## Installation\n\nJust puts `migrate.php` file in your direcotry.\n\n    wget https://raw.github.com/kohkimakimoto/phpmigrate/master/migrate.php\n\n## Getting Started\n\nConfigure to connect your MySQL database to migrate.\n\nPlease open `migrate.php` downloaded. And modify below settings for your environment.\n\n    $database_config = array(\n      // Database settings.\n      'yourdatabase' =\u003e array(\n        // PDO Connection settings.\n        'database_dsn'      =\u003e 'mysql:dbname=yourdatabase;host=localhost',\n        'database_user'     =\u003e 'user',\n        'database_password' =\u003e 'password',\n\n        // schema version table\n        'schema_version_table' =\u003e 'schema_version'\n      ),\n\nor\n\n    $database_config = array(\n      // Database settings.\n      'yourdatabase' =\u003e array(\n        // mysql client command settings.\n        'mysql_command_enable'    =\u003e true,\n        'mysql_command_cli'       =\u003e \"/usr/bin/mysql\",\n        'mysql_command_tmpsqldir' =\u003e \"/tmp\",\n        'mysql_command_host'      =\u003e \"localhost\",\n        'mysql_command_user'      =\u003e \"user\",\n        'mysql_command_password'  =\u003e \"password\",\n        'mysql_command_database'  =\u003e \"yourdatabase\",\n        'mysql_command_options'   =\u003e \"--default-character-set=utf8\",\n\n        // schema version table\n        'schema_version_table' =\u003e 'schema_version'\n      ),\n\nDifference between settings of `database_xxx` and `mysql_command_xxx` is database connection to execute SQL.\nAt default, it uses `database_xxx` settings to connect database using PDO.\nYou set up that `mysql_command_enable` is **true**. It uses `mysql_command_xxx` settings to connect databse using mysql client command.\nIf you use `delimeter` command in your SQL. You need to use `mysql_command_xxx` settings. Because `delimeter` command is not a SQL.\nIt's a mysql client command.\n\nAnd create migration class file. Run the following command\n\n    php migrate.php create create_sample_table\n\nYou would get the following messages and the skeleton migration file.\n`20130422155835` timestamp part depeneds on your environment.\n\n    Created 20130422155835_create_sample_table.php\n\nOpen the `20130422155835_create_sample_table.php`. And modify `getUpSQL` and `getDownSQL` method like below.\n\n      /**\n       * Return the SQL statements for the Up migration\n       *\n       * @return string The SQL string to execute for the Up migration.\n       */\n      public function getUpSQL()\n      {\n         return \u003c\u003c\u003cEND\n\n    CREATE TABLE `sample` (\n      `id` INT UNSIGNED NOT NULL,\n      PRIMARY KEY (`id`) )\n    ENGINE = InnoDB\n    DEFAULT CHARACTER SET = utf8\n    COLLATE = utf8_bin;\n\n    END;\n      }\n\n    /**\n     * Return the SQL statements for the Down migration\n     *\n     * @return string The SQL string to execute for the Down migration.\n     */\n    public function getDownSQL()\n    {\n        return \u003c\u003c\u003cEND\n\n       DROP TABLE `sample`;\n\n    END;\n    }\n\nOK. You are ready to execute migrate command. Run the following command.\n\n    php migrate.php migrate\n\nYou would get below messages. and table be created in your mysql database.\n\n    [yourdatabase] Current schema version is 0\n    [yourdatabase] Proccesing migrate up by 20130422155835_create_sample_table.php\n\nAlso you can run migration `down` command like the following.\n\n    php migrate.php down\n\nThis commad drop your sample table.\n\n\n## Command Usage\n\n    php migrate.php [-h|-d|-c] COMMAND\n\n## Options\n\n### -d\n\nSwitch the debug mode to output log on the debug level.\n\n### -h\n\nList available command line options.\n\n### -c\n\nList configurations.\n\n## Commands\n\n### create\n\nCreate new skeleton migration file.\n\n* Exsamples\n\n        php migrate.php create foo\n\n### status [DATABASENAME ...]\n\nList the migrations yet to be executed.\n\n* Exsamples\n\n        php migrate.php status\n\n### migrate [DATABASENAME ...]\n\nExecute the next migrations up.\n\n* Exsamples\n\n        php migrate.php migrate\n\n### up [DATABASENAME ...]\n\nExecute the next migration up.\n\n* Exsamples\n\n        php migrate.php up\n\n### down [DATABASENAME ...]\n\nExecute the next migration down.\n\n* Exsamples\n\n        php migrate.php down\n\n## License\n\n  Apache License 2.0\n\n## Infomation\n\nMy Blog post (written in Japanese)\n\n * http://kohkimakimoto.hatenablog.com/entry/2013/04/02/201308\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkohkimakimoto%2Fphpmigrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkohkimakimoto%2Fphpmigrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkohkimakimoto%2Fphpmigrate/lists"}