techsemicolon/laravel-migration-pipeline
Composer 安装命令:
composer require techsemicolon/laravel-migration-pipeline
包简介
A migration pipeline to make sure same migration is not run again in multiple server setup
README 文档
README
A migration pipeline to make sure same migration is not run again in multiple server setup
Version Support :
Works for Laravel version 5.3 and above.
Introduction :
When you run php artisan migrate in laravel, it checks if there are any new migration files which are not yet migrated. If yes, then it runs each migration one by one and adds an entry into migrations table with migration name and batch number.
However, when you have multiple servers on autoscalling and have the CICD pipelines to automatically pull the latest releases of git webhooks, the post webhook script having php artisan migrate runs almost simultaneously on all those servers.
For example lets say, you have 3 laravel servers running. When you push latest releases to git, git webhook triggers the CICD pipeline and then all servers receive the webhooks almost at the same time.
All these 3 servers will run webhook scripts, which will have git pull and then php artisan commands. One of which will be php artisan migrate. If you have 3 new migrations in the release, all these 3 will be attempted to run with different(mostly consecutive) batch numbers.
We want to avoid that. If a migration is already run on the 1st server out of 3, we do not want 2nd and 3rd server to re-run it. This is when this package comes into picture.
In any given situation, if a migration is running on one server or already run ina different batch number, it will not run again. This will avoid the above problem.
Installation :
To install the package using composer :
composer require techsemicolon/gitdeployer
Once installed, you can add service provider in config/app.php file for laravel version <= 5.4. For later versions the service provider will be automatically included.
Techsemicolon\MigrationPipeline\ServiceProvider::class,
Example :
Following screenshot gives you an idea where both the servers are running php artisan migrate at the same time. However, the right server ran migration_1 hence, left server skipped that and ran the remaining ones.
Also, once the migration_1 was ran by right server, migration_2, migration_3 and migration_4 were skipped because those were already run by the left server.
Note :
This package assumes/requires that you give unique names to your migrations. By default each migration in laravel is unique if you use php artisan make:migration some_table_migration where laravel adds timestamp at the start of migration file name. But in case you are removing that timestamp, make sure you have something in the migration file name which marks it as unique.
License :
This package is open-sourced software licensed under the MIT license
techsemicolon/laravel-migration-pipeline 适用场景与选型建议
techsemicolon/laravel-migration-pipeline 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 04 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 techsemicolon/laravel-migration-pipeline 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 techsemicolon/laravel-migration-pipeline 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-09
