{"id":37233243,"url":"https://github.com/thinkphp6/thinkphp-migration-generator","last_synced_at":"2026-01-15T03:53:15.841Z","repository":{"id":57068872,"uuid":"391225058","full_name":"thinkphp6/thinkphp-migration-generator","owner":"thinkphp6","description":"thinkphp migration generator , ThinkPHP 数据库反向生成工具","archived":false,"fork":false,"pushed_at":"2021-12-02T07:03:04.000Z","size":45,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-06T14:18:05.480Z","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thinkphp6.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}},"created_at":"2021-07-31T01:16:14.000Z","updated_at":"2025-01-24T01:44:31.000Z","dependencies_parsed_at":"2022-08-24T10:20:40.874Z","dependency_job_id":null,"html_url":"https://github.com/thinkphp6/thinkphp-migration-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thinkphp6/thinkphp-migration-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp6%2Fthinkphp-migration-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp6%2Fthinkphp-migration-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp6%2Fthinkphp-migration-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp6%2Fthinkphp-migration-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinkphp6","download_url":"https://codeload.github.com/thinkphp6/thinkphp-migration-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp6%2Fthinkphp-migration-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28419272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-15T03:53:15.252Z","updated_at":"2026-01-15T03:53:15.826Z","avatar_url":"https://github.com/thinkphp6.png","language":"PHP","readme":"# Migration Generator - Mysql数据表反向迁移文件生成\n\n如果你还未使用或者正想使用数据库迁移功能，但又不并不想自己写迁移文件的话，这个工具可以很好的帮助实现文件迁移，\n目前提供了 Laravel5.5+ 和 Thinkphp6+ 的迁移文件的生成。\n        \n源项目: https://github.com/JaguarJack/migration-generator      \n因为原本的存在一些BUG , Fork一个版本修复下\n        \n        \n更新日志:       \n - [x] 修复DateTime大小写问题\n - [x] 增加SimpleArrayType 修复Set类型导致异常问题\n        \n        \n## 安装\n```sh\ncomposer require thinkphp6/thinkphp-migration-generator:dev-main\n```\n\n## 平台支持\n#### laravel\n```shell\nphp artisan migration:generate\n```\n\n#### ThinkPHP\n```\nphp think migration:generate\n```\n#### 注意\n\u003e 包中提供的命令如果不能完全满足你的需求，那么你可以根据实际自定义需求。\n\n### 定义新类型\n\n- 继承 \\Doctrine\\DBAL\\Types\\Type\n```php\nclass newType extend \\Doctrine\\DBAL\\Types\\Type{} \n```\n- 主要实现两个方法\n\n```php\npublic function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)\n{\n    return $platform-\u003egetIntegerTypeDeclarationSQL($fieldDeclaration);\n}\n\npublic function getName()\n{\n    return 'TypeName';\n}\n```\n\n- 注入\n\n```php\n$generator = new MigrateGenerator('thinkphp');\n$generator-\u003eregisterNewType([\n    'TypeName' =\u003e TypeClass\n]);\n```\n\n### 新增类型解析\n\u003e 就是对应框架 migration 的格式\n\n- 继承实现\n```php\nclassType extend JaguarJack\\MigrateGenerator\\Migration\\Columns\\AbstractType\n{}\n```\n  \n\u003e 继承这个基类可以获取两个信息\n    - 获取当前 `column` 的所有信息\n    - 整个表结构的原始信息 这里可以得到 `DBAL` 不会提供的信息\n    \n- 必须实现的两个方法\n\u003e 因为现在就支持了 laravel 和 thinkphp 所有就定义了这两个方法\n\n```php\n    public function laravelMigrationColumn():string\n\n    public function thinkphpMigrationColumn():string\n```\n\n- 注入\n\n```php\n$generator = new MigrateGenerator('thinkphp');\n$generator-\u003eregisterNewTypeParse([\n    'TypeClassName' =\u003e ParseTypeClass\n]);\n```\n\u003e `TypeClassName` 指的就是新类型的类的名称\n`ParseTypeClass` 也必须和 `TypeClass` 相同，这是约定，方便更好的解析。\n\n\n### 其他\n\n除了提供的自定义的命令外，通过两个对外接口自己生成文件\n```php\n$generator-\u003egetDatabase;\n```\n\u003e 这个方法可以获取表信息以及字段信息等等\n\n```php\n$generator-\u003egetMigrationContent;\n```\n\u003e 这个方法可以获取解析后 migration 文件内容\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkphp6%2Fthinkphp-migration-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinkphp6%2Fthinkphp-migration-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkphp6%2Fthinkphp-migration-generator/lists"}