oscarafdev/migrations-generator
Composer 安装命令:
composer require oscarafdev/migrations-generator
包简介
Generates Laravel Migrations from an existing database
README 文档
README
Generate Laravel Migrations from an existing database, including indexes and foreign keys!
Versioning & compatibility
| Branch / Tag | Laravel support | PHP support | Notes |
|---|---|---|---|
laravel-12.x (12.0.0) |
12.x | >= 8.3 | Uses doctrine/dbal:^4.0 to match the Laravel 12 / Carbon 3 ecosystem. |
laravel-11.x (11.0.0) |
11.x | >= 8.2 | Use ^11.0 for Laravel 11 apps. |
laravel-10.x (10.0.0) |
10.x | >= 8.1 | Use ^10.0 for Laravel 10 apps. |
laravel-9.x (9.0.0) |
9.x | >= 8.2 | Use ^9.0 to stay on the Laravel 9-compatible line. |
Legacy 2.x (2.0.24) |
5.x – 8.x | ^5.6 || ^7.0 || ^8.0 | Last release for older apps (ships with the legacy generator dependency). |
Each Laravel major has its own maintenance branch/tag series (e.g. laravel-12.x -> 12.y.z). See doc/versions.md for the full compatibility matrix.
Contact
Laravel 6/7/8/9/10/11/12 installation
The recommended way to install this is through composer:
composer require oscarafdev/migrations-generator --dev
For Laravel 12, the 12.x line now targets doctrine/dbal:^4.0, which aligns with the Carbon 3 dependency tree used by that ecosystem.
In Laravel 5.5+ the service providers will automatically get registered.
Usage
To generate migrations from a database, you need to have your database setup in Laravel's Config.
Run php artisan migrate:generate to create migrations for all the tables, or you can specify the tables you wish to generate using php artisan migrate:generate table1,table2,table3,table4,table5. You can also ignore tables with --ignore="table3,table4,table5"
Laravel Migrations Generator will first generate all the tables, columns and indexes, and afterwards setup all the foreign key constraints. So make sure you include all the tables listed in the foreign keys so that they are present when the foreign keys are created.
You can also specify the connection name if you are not using your default connection with --connection="connection_name"
Run php artisan help migrate:generate for a list of options.
Check out Chung Tran's blog post for a quick step by step introduction: Generate Migrations from an existing database in Laravel 4
Changelog
Changelog for Laravel Migrations Generator
Jan 2021: v2.0.24
- Support for Laravel 8
- Fixed a issue where double single quotes were generated
Ago 2020: v2.0.23
- Added support for precisions in timestamp.
- Fixed an issue with the text type.
- Fixed other reported bugs
May 2020: v2.0.19
- Support for Laravel 7
Thank You
Thanks to Jeffrey Way for his amazing Laravel-4-Generators package. This package depends greatly on his work.
Contributors
Bernhard Breytenbach (@BBreyten)
Oscar Fernandez (@oscarafdev)
License
The Laravel Migrations Generator is open-sourced software licensed under the MIT license
oscarafdev/migrations-generator 适用场景与选型建议
oscarafdev/migrations-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 593k 次下载、GitHub Stars 达 360, 最近一次更新时间为 2019 年 11 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「migrations」 「generator」 「migration」 「laravel」 「artisan」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 oscarafdev/migrations-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 oscarafdev/migrations-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 oscarafdev/migrations-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Symfony ClickhouseMigrationsBundle
Very simple SQL-based database migrations tool - a heavily stripped down fork of robmorgan/phinx
Laravel table comments loader (part of Diplodocker project)
Lets you add foreign keys in a swift! Foreign key adder in laravel migration.
A lightweight, secure-by-default PHP microframework built on Slim – providing Laravel-like features (ORM, authentication, migrations, caching) without the bloat. Perfect for building REST APIs and small-to-medium PHP applications.
统计信息
- 总下载量: 593k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 364
- 点击次数: 32
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-11-30