{"id":19756816,"url":"https://github.com/imiphp/imi-migration","last_synced_at":"2025-04-30T12:30:46.353Z","repository":{"id":59962346,"uuid":"539869858","full_name":"imiphp/imi-migration","owner":"imiphp","description":"imi 框架的数据库迁移组件","archived":false,"fork":false,"pushed_at":"2023-07-03T00:54:26.000Z","size":40,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"2.1","last_synced_at":"2024-05-23T01:33:09.594Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imiphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-09-22T08:11:37.000Z","updated_at":"2022-09-25T08:11:41.000Z","dependencies_parsed_at":"2022-09-25T11:54:39.608Z","dependency_job_id":null,"html_url":"https://github.com/imiphp/imi-migration","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"df0f14546032cdf37dcee9ea4a6b984bc79fa12e"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-migration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-migration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-migration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-migration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imiphp","download_url":"https://codeload.github.com/imiphp/imi-migration/tar.gz/refs/heads/2.1","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224207897,"owners_count":17273674,"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":[],"created_at":"2024-11-12T03:17:01.493Z","updated_at":"2024-11-12T03:17:02.155Z","avatar_url":"https://github.com/imiphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# imi-migration\n\n[![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-migration.svg)](https://packagist.org/packages/imiphp/imi-migration)\n[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/)\n[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src)\n[![imi License](https://img.shields.io/badge/license-MulanPSL%202.0-brightgreen.svg)](https://github.com/imiphp/imi-migration/blob/master/LICENSE)\n\n## 介绍\n\n此项目是 imi 框架的数据库迁移组件。\n\n\u003e 正在测试阶段，使用时请先确认 SQL 无误后再执行，本项目不对删库删数据负责。\n\n## 安装\n\n`composer require imiphp/imi-migration:~2.1.0`\n\n## 使用说明\n\n### 模型同步到表结构\n\n#### 同步表结构\n\n将数据库中的数据表结构升级为模型中定义的结构。\n\n```shell\nvendor/bin/imi-swoole migration/patch -f\n```\n\n#### 生成同步结构 SQL 语句\n\n**输出到命令行：**\n\n```shell\nvendor/bin/imi-swoole migration/patch\n```\n\n**保存到文件：**\n\n```shell\nvendor/bin/imi-swoole migration/patch -f \"文件名\"\n```\n\n### 数据库迁移\n\n#### 配置\n\n`@app.beans`:\n\n```php\n[\n    \\Imi\\Migration\\Service\\MigrationService::class =\u003e [\n        'handler' =\u003e \\Imi\\Migration\\Handler\\FileMigrationHandler::class, // 迁移处理器\n        'onGenerateModel' =\u003e true, // 是否在生成模型时自动生成迁移文件\n    ],\n]\n```\n\n\u003e 上述配置是默认配置，不配置时自动启用。\n\n#### 目录\n\n`.migration` 是存放数据库迁移文件和版本信息的目录，请勿将 `.migration/version` 提交到版本控制系统。\n\n#### 执行数据库迁移\n\n**执行前询问：**\n\n```shell\nvendor/bin/imi-swoole migration/migrate\n```\n\n**强制执行：**\n\n```shell\nvendor/bin/imi-swoole migration/migrate -f\n```\n\n\u003e 请谨慎操作\n\n### 执行数据库回滚\n\n**执行前询问：**\n\n```shell\nvendor/bin/imi-swoole migration/rollback\n```\n\n**强制执行：**\n\n```shell\nvendor/bin/imi-swoole migration/rollback -f\n```\n\n\u003e 请谨慎操作\n\n### 通用参数\n\n#### 指定连接池\n\n```shell\nvendor/bin/imi-swoole migration/命令 --poolName \"连接池名\"\n```\n\n\u003e 不指定时使用默认连接池\n\n#### 指定连接参数\n\n```shell\nvendor/bin/imi-swoole migration/命令 --driver \"PdoMysqlDriver\" --options \"host=127.0.0.1\u0026port=3306\u0026username=root\u0026password=root\"\n```\n\n## 免费技术支持\n\nQQ群：17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png \"点击加群\")](https://jq.qq.com/?_wv=1027\u0026k=5wXf4Zq)，如有问题会有人解答和修复。\n\n## 运行环境\n\n* [PHP](https://php.net/) \u003e= 7.4\n* [Composer](https://getcomposer.org/) \u003e= 2.0\n* [Swoole](https://www.swoole.com/) \u003e= 4.8.0\n* [imi](https://www.imiphp.com/) \u003e= 2.1\n\n## 版权信息\n\n`imi-migration` 依赖 [phpmyadmin/sql-parser](https://github.com/phpmyadmin/sql-parser)，所以开源协议受到污染，必须是 GPL-2.0，所有基于本项目的代码都要开源。\n\n建议仅将此组件作为独立工具安装使用，不要在项目中调用此项目中的任意代码，这样就不受开源协议污染了！\n\n## 捐赠\n\n\u003cimg src=\"https://cdn.jsdelivr.net/gh/imiphp/imi@2.1/res/pay.png\"/\u003e\n\n开源不求盈利，多少都是心意，生活不易，随缘随缘……\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimiphp%2Fimi-migration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimiphp%2Fimi-migration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimiphp%2Fimi-migration/lists"}