codebider/seeder-versioning-tool
最新稳定版本:v0.0.2
Composer 安装命令:
composer require codebider/seeder-versioning-tool
包简介
A Laravel package to versioning the seeders using an Artisan command.
README 文档
README
A Laravel package to manage and version database seeders using Artisan commands. This tool ensures that seeders are executed in a controlled and chronological order, with support for modules and batch tracking.
📦 Installation
You can install the package via Composer:
composer require codebider/seeder-versioning-tool
If you’re using Laravel < 5.5, add the service provider manually in config/app.php:
'providers' => [ CodeBider\versionSeeder\versionSeederServiceProvider::class, ];
⚙️ Configuration (Optional)
You can publish the migration and stub files using:
php artisan vendor:publish --provider="CodeBider\versionSeeder\versionSeederServiceProvider"
Make sure to run the migration to create the seeders table:
php artisan vendor:publish --tag=migrations php artisan migrate
This will publish:
database/migrations/2025_04_29_171328_create_seeders_table.phpstubs/versioned_seeder.stub
🧪 Usage
Running Versioned Seeders
Run all versioned seeders in chronological order:
php artisan db:seed:versioned
Options:
--connection=: Specify the database connection.--database=: Specify the database name.--module=: Run seeders for a specific module.
Creating a Versioned Seeder
Generate a new versioned seeder file:
php artisan make:seeder:versioned SeederName
Options:
--module=: Specify the module name for the seeder.
This will create a timestamped seeder file in the database/seeders/Versioned directory (or inside the specified module).
🛠 How It Works
-
Versioned Seeder Execution:
- Seeders are executed in chronological order based on their file creation time.
- Each seeder is tracked in the
seederstable to prevent duplicate execution.
-
Batch Tracking:
- Seeders are grouped into batches for better tracking and rollback capabilities.
-
Module Support:
- Seeders can be organized into modules for better separation of concerns.
-
Custom Stub:
- The default stub file for versioned seeders can be customized by modifying the published
stubs/versioned_seeder.stub.
- The default stub file for versioned seeders can be customized by modifying the published
✏️ Custom Stub
The stub file supports the following variables:
{{ namespace }}{{ class }}
Example stub:
<?php namespace {{ namespace }}; use App\Console\VersionedSeeder; class {{ class }} extends VersionedSeeder { public function run() { // Add your seeding logic here } }
📄 License
This package is open-sourced software licensed under the MIT license.
👤 Author
Developed with ❤️ by Awais Javaid
📦 Package: codebider/seeder-versioning-tool
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request or open an issue.
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-29