dilneiss/laravel-migrations-generator
Composer 安装命令:
composer require dilneiss/laravel-migrations-generator
包简介
Generates Laravel Migrations from an existing database
README 文档
README
Generate Laravel Migrations from an existing database, including indexes and foreign keys!
This package is cloned from https://github.com/Xethron/migrations-generator and updated to support Laravel 5.6 and above, with a lot of feature improvements.
Supported Database
Currently, Generator support generate migrations from:
- MySQL
- PostgreSQL
- SQL Server
Version Compatibility
| Laravel | Version |
|---|---|
| 8.x | 5.x |
| 7.x | 5.x |
| 6.x | 5.x |
| 5.8.x | 5.x |
| 5.7.x | 5.x |
| 5.6.x | 5.x |
| 5.5 and below | https://github.com/Xethron/migrations-generator |
Install
The recommended way to install this is through composer:
composer require --dev "kitloong/laravel-migrations-generator"
Laravel Setup
Laravel will automatically register service provider for you.
Lumen Setup
Auto-discovery is not available in Lumen, you need some modification on bootstrap/app.php.
Enable facade
Uncomment the following line.
$app->withFacades();
Register provider
Add following line into the Register Service Providers section.
$app->register(\MigrationsGenerator\MigrationsGeneratorServiceProvider::class);
Usage
To generate migrations from a database, you need to have your database setup in Laravel's config (config/database.php).
To create migrations for all the tables, run:
php artisan migrate:generate
You can specify the tables you wish to generate using:
php artisan migrate:generate --tables="table1,table2,table3,table4,table5"
You can also ignore tables with:
php artisan migrate:generate --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:
php artisan migrate:generate --connection="connection_name"
Squash migrations
By default, Generator will generate multiple migration files for each table.
You can squash all migrations into a single file with:
php artisan migrate:generate --squash
Options
Run php artisan help migrate:generate for a list of options.
| Options | Description |
|---|---|
| -c, --connection[=CONNECTION] | The database connection to use |
| -t, --tables[=TABLES] | A list of Tables or Views you wish to Generate Migrations for separated by a comma: users,posts,comments |
| -i, --ignore[=IGNORE] | A list of Tables or Views you wish to ignore, separated by a comma: users,posts,comments |
| -p, --path[=PATH] | Where should the file be created? |
| -tp, --template-path[=TEMPLATE-PATH] | The location of the template for this generator |
| --date[=DATE] | Migrations will be created with specified date. Views and Foreign keys will be created with + 1 second. Date should be in format suitable for Carbon::parse |
| --table-filename[=TABLE-FILENAME] | Define table migration filename, default pattern: [datetime_prefix]\_create_[table]_table.php |
| --view-filename[=VIEW-FILENAME] | Define view migration filename, default pattern: [datetime_prefix]\_create_[table]_view.php |
| --fk-filename[=FK-FILENAME] | Define foreign key migration filename, default pattern: [datetime_prefix]\_add_foreign_keys_to_[table]_table.php |
| --default-index-names | Don't use db index names for migrations |
| --default-fk-names | Don't use db foreign key names for migrations |
| --use-db-collation | Follow db collations for migrations |
| --skip-views | Don't generate views |
| --squash | Generate all migrations into a single file |
Thank You
Thanks to Bernhard Breytenbach for his great work. This package is cloned from https://github.com/Xethron/migrations-generator.
Thanks to Jeffrey Way for his amazing Laravel-4-Generators package. This package depends greatly on his work.
Contributors
License
The Laravel Migrations Generator is open-sourced software licensed under the MIT license
dilneiss/laravel-migrations-generator 适用场景与选型建议
dilneiss/laravel-migrations-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 558 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「migrations」 「generator」 「migration」 「laravel」 「artisan」 「lumen」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dilneiss/laravel-migrations-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dilneiss/laravel-migrations-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dilneiss/laravel-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.
统计信息
- 总下载量: 558
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-09