sonole/laravel-db-seed-rollback
Composer 安装命令:
composer require sonole/laravel-db-seed-rollback
包简介
关键字:
README 文档
README
Introduction
In the context of package development, particularly those involving database seeders, I propose the introduction of the --rollback option for the db:seed command. This feature complements the existing migrate:rollback command and offers a solution for efficient database seeding management.
The Problem
Currently, many projects rely on packages that utilize seeders to alter the database. However, when complications arise, such as errors, changes in requirements, or the need to remove packages, there is a lack of streamlined mechanisms to revert these seeding changes. While the migrate:rollback command helps with migrations, the absence of a corresponding option for seeders presents challenges in complex projects where multiple custom packages are involved.
The Solution
By introducing the --rollback option for the db:seed command, package developers and maintainers can now address these issues.
Use Case
Just run db:seed with the --rollback option and down() function will be invoked!
php artisan db:seed --class="Vendor\\Package\\Database\\Seeders\\UsersSeeder" --rollback #or php artisan db:seed --rollback
namespace Vendor\Package\Database\Seeders /** If your seeder does not extend the package's Seeder: * Sonole\LaravelDbSeedRollback\Illuminate\Database\Seeder * then a new temporary file will be created at database/seeders, and it will be deleted after down() execution. */ use Illuminate\Database\Seeder; class UsersSeeder extends Seeder { /** * Seed the application's database. */ public function run(): void { //\App\Models\User::factory(10)->create(); // \App\Models\User::factory()->create([ // 'name' => 'Test User', // 'email' => 'test@example.com', // ]); } /** * Reverse the effects of the database seeding operation. */ public function down(): void { \App\Models\User::where('email', 'foo@bar.com')->delete(); } }
sonole/laravel-db-seed-rollback 适用场景与选型建议
sonole/laravel-db-seed-rollback 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 32 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「db」 「laravel」 「seed」 「rollback」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sonole/laravel-db-seed-rollback 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sonole/laravel-db-seed-rollback 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sonole/laravel-db-seed-rollback 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Advanced seeding for laravel framework
Export your database quickly and easily as a Laravel Migration and all the data as a Seeder class.
Generate Laravel seed files from database state. This is a fork of orangehill/iseed that includes support for Laravel 8
Versioned, environment-based Seeders in Laravel. Used while original does not update to Laravel 5.7
A model factory package for Laravel 4 with expressive API for creating custom tailored dummy objects
统计信息
- 总下载量: 32
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-02