manage-seeders

Database Seeder Manager Skill

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "manage-seeders" with this command: npx skills add iurygdeoliveira/labsis-kit/iurygdeoliveira-labsis-kit-manage-seeders

Database Seeder Manager Skill

Use this skill to create or refactor Seeders, especially when moving from hardcoded data to JSON files or factories.

Core Rules

  1. Idempotency (Run Multiple Times Safe)
  • Seeders MUST be safe to run multiple times without creating duplicate dirty data.

  • Use updateOrCreate or firstOrCreate based on a unique key (e.g., slug , email , code ).

  1. JSON Data Source Pattern

When populating data from JSON files (e.g., database/data/*.json ):

  • Read File: Use file_get_contents and json_decode .

  • Iterate: Loop through the array.

  • Persist: Use updateOrCreate .

$json = file_get_contents(database_path('data/categories.json')); $categories = json_decode($json, true);

foreach ($categories as $data) { Category::updateOrCreate( ['slug' => $data['slug']], // Unique Key [ 'name' => $data['name'], 'description' => $data['description'] ?? null, ] ); }

  1. Removing IDs
  • Never force id from JSON unless it's a critical system constant. Let the database Auto-Increment handle IDs.

  • If relationships rely on specific "codes" in the JSON, look up the related ID by that code, do not hardcode the foreign ID.

  1. Registration
  • Always check if the Seeder is called in DatabaseSeeder.php . If not, register it.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

scaffold-filament-resource

No summary provided by upstream source.

Repository SourceNeeds Review
General

scaffold-controller

No summary provided by upstream source.

Repository SourceNeeds Review
General

scaffold-filament-page

No summary provided by upstream source.

Repository SourceNeeds Review
General

manage-git

No summary provided by upstream source.

Repository SourceNeeds Review