Download the PHP package nomanurrahman/fresh-seed without Composer
On this page you can find all versions of the php package nomanurrahman/fresh-seed. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nomanurrahman/fresh-seed
More information about nomanurrahman/fresh-seed
Files in nomanurrahman/fresh-seed
Package fresh-seed
Short Description seed and refresh every single table
License MIT
Homepage https://github.com/nomanurrahman/fresh-seed
Informations about the package fresh-seed
Laravel Fresh Seed
A lightweight Laravel package that allows you to truncate and re-seed database tables surgically. This is perfect for development when you need to refresh specific data without running a full migrate:fresh --seed which wipes your entire database.
Features
- π― Surgical Refresh: Truncate/delete only the tables you specify.
- π Multi-Table Support: Refresh multiple tables at once (e.g.,
users,posts). - π Table Presets/Groups: Define curated groups of tables in the config to refresh together.
- πΊοΈ Interactive Selection: Run the command without arguments to select tables from an interactive console prompt.
- π Dry-Run Preview: Preview what actions would be performed without actually modifying database records.
- π Custom Database Connections: Execute the operations against a non-default connection.
- π‘οΈ Constraint Safety & Safe Deletion: Disables foreign key constraints during the process, with an optional
--safemode utilizingDELETEinstead ofTRUNCATEto support transactions and avoid implicit database commits. - βοΈ Auto-Seeder Detection: Automatically locates appropriate seeders using standard Laravel conventions.
Installation
Install the package via composer as a development dependency:
Configuration (Optional)
To configure presets/groups or default connections, publish the configuration file:
This will create a config/fresh-seed.php file:
Usage
1. Interactive Selection
Run the command without options to select which table(s) to refresh interactively:
2. Basic Single-Table Refresh
Refresh a single table and let the package locate the matching seeder automatically:
Note: For safety, the command asks for confirmation if run in a production environment. You can bypass this with the
--forceflag.
3. Multi-Table Refresh
Refresh multiple tables sequentially using a comma-separated list:
4. Running Table Groups
Refresh pre-configured groups defined in config/fresh-seed.php:
5. Specifying a Custom Seeder
Explicitly define a custom seeder class (only valid when refreshing a single table):
6. Safe Deletions
Use DELETE instead of TRUNCATE to avoid implicit database commits (useful for maintaining database transaction integrity):
7. Dry-Run Mode
Preview the execution path without modifying database records:
8. Targeting a Custom Connection
Run the refresh against a secondary or tenant database connection:
How Seeder Detection Works
If you don't provide a --seeder option or group mapping, the package looks for seeders in the following order:
StudlyCaseTableNameTableSeeder(e.g.,UsersTableSeeder)StudlyCaseSingularTableNameSeeder(e.g.,UserSeeder)
Checks are conducted in both the root namespace and the standard Database\Seeders\ namespace.
Testing
The package includes a comprehensive test suite. You can run the tests using:
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Credits
- nomanur rahman
- All Contributors
License
The MIT License (MIT). Please see License File for more information.