Skip to content

feat: [#797] Add WithSeeders function#1262

Merged
hwbrzzl merged 2 commits intomasterfrom
bowen/#797
Nov 16, 2025
Merged

feat: [#797] Add WithSeeders function#1262
hwbrzzl merged 2 commits intomasterfrom
bowen/#797

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Nov 16, 2025

📑 Description

Closes goravel/goravel#797

This pull request introduces first-class support for database seeders in the Goravel framework by adding a new WithSeeders method to the application builder and automating the registration of seeders in bootstrap setup. The changes streamline seeder creation and registration, improve test coverage, and enhance the codebase to support future removal of legacy kernel-based registration.

image

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings November 16, 2025 09:27
@hwbrzzl hwbrzzl requested a review from a team as a code owner November 16, 2025 09:27
@codecov
Copy link

codecov bot commented Nov 16, 2025

Codecov Report

❌ Patch coverage is 73.49398% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.07%. Comparing base (1ea5774) to head (c735bff).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
packages/modify/actions.go 82.43% 7 Missing and 6 partials ⚠️
foundation/application_builder.go 0.00% 8 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1262      +/-   ##
==========================================
+ Coverage   68.04%   68.07%   +0.02%     
==========================================
  Files         261      261              
  Lines       15271    15354      +83     
==========================================
+ Hits        10391    10452      +61     
- Misses       4432     4447      +15     
- Partials      448      455       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces first-class support for database seeders in the Goravel framework by adding a new WithSeeders method to the ApplicationBuilder. The implementation mirrors the existing migration support pattern and includes automated registration in bootstrap setup, allowing seeders to be registered declaratively alongside other application components.

Key changes:

  • Added WithSeeders method to ApplicationBuilder interface and implementation for registering database seeders
  • Implemented AddSeeder function in the modify package to automatically add seeders to bootstrap configuration
  • Updated SeederMakeCommand to use the new bootstrap setup when available, with fallback to legacy kernel registration

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
contracts/foundation/application_builder.go Added WithSeeders method to ApplicationBuilder interface
foundation/application_builder.go Implemented WithSeeders method and seeder registration logic in Create()
mocks/foundation/ApplicationBuilder.go Generated mock implementation for WithSeeders method
packages/modify/actions.go Added AddSeeder function and supporting helpers to modify bootstrap files
packages/modify/actions_test.go Comprehensive test coverage for AddSeeder and related functions
database/console/seeder_make_command.go Updated to use bootstrap setup via AddSeeder when available
database/console/seeder_make_command_test.go Added tests for bootstrap setup integration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// Into:
//
// foundation.Setup().WithSeeders([]seeder.Seeder{
// &seeders.ExampleMigration{},
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation example references "ExampleMigration" instead of "ExampleSeeder". This should be corrected for consistency.

Example:

//	foundation.Setup().WithSeeders([]seeder.Seeder{
//	  &seeders.ExampleSeeder{},
//	}).WithConfig(config.Boot).Run()

Copilot uses AI. Check for mistakes.
@krishankumar01
Copy link
Member

My only concern is that bootstrap/app.go will grow too large, so we might need to create separate files for functions like WithMigrations, WithSeeders, and others.

@hwbrzzl
Copy link
Contributor Author

hwbrzzl commented Nov 16, 2025

My only concern is that bootstrap/app.go will grow too large, so we might need to create separate files for functions like WithMigrations, WithSeeders, and others.

Yes, will optimize it next.

@hwbrzzl hwbrzzl merged commit 882b9e0 into master Nov 16, 2025
14 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#797 branch November 16, 2025 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SUB-786] Add WithSeeders function

3 participants