Skip to content

πŸš€ Introducing SeedSpotter: A Laravel Package for Database Seeder Verification 🌱

License

Notifications You must be signed in to change notification settings

abdulmannans/seed-spotter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SeedSpotter

SeedSpotter is a Laravel package that helps you detect discrepancies between your database seeders and the actual database content. It's an essential tool for maintaining data integrity in your Laravel applications.

Features

  • Compare seeder data with actual database content
  • Detect missing, extra, or different rows
  • Ignore specified columns in comparisons
  • Easy-to-use Artisan command
  • Configurable through Laravel's config system

Installation

You can install the package via composer:

composer require abdulmannans/seed-spotter

The package will automatically register its service provider.

Usage

Using the Artisan Command

The easiest way to use SeedSpotter is through its Artisan command:

php artisan seed-spotter:compare "Database\Seeders\YourSeeder" --table=your_table_name

This command will run the comparison and display the results in your console.

Using in Code

You can also use SeedSpotter in your PHP code:

use Abdulmannans\SeedSpotter\Facades\SeedSpotter;

$result = SeedSpotter::compare(YourSeederClass::class, "your_table_name");

if ($result["has_discrepancies"]) {
  foreach ($result["discrepancies"] as $discrepancy) {
    // Handle discrepancy
  }
} else {
  // Data is in sync
}

Configuration

To customize SeedSpotter's behavior, you can publish the configuration file:

php artisan vendor:publish --provider="Abdulmannans\SeedSpotter\SeedSpotterServiceProvider" --tag="config"

This will create a config/seed-spotter.php file. Here are the available options:

return [
  // The default table to check if not specified
  "table" => "users",

  // Columns to ignore in comparisons
  "ignore_columns" => ["created_at", "updated_at"],
];

Testing

To run the package tests, use:

composer test

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

The MIT License (MIT). Please see License File for more information.

Credits

Support

If you discover any security related issues, please email [email protected] instead of using the issue tracker.


Made with ❀️ by Abdul Mannan(https://github.com/abdulmannans)