Skip to content

feat: [#649] auto-register migration and seeder when created via CLI#1011

Merged
almas-x merged 3 commits intomasterfrom
almas/#649
Apr 17, 2025
Merged

feat: [#649] auto-register migration and seeder when created via CLI#1011
almas-x merged 3 commits intomasterfrom
almas/#649

Conversation

@almas-x
Copy link
Contributor

@almas-x almas-x commented Apr 16, 2025

📑 Description

Closes goravel/goravel#649

This change improves workflow efficiency by automatically registering migration and seeder files created via artisan make:migration and artisan make:seeder.

These files are now injected into database/kernel.go, eliminating the need for manual inclusion and streamlining the setup process.

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings April 16, 2025 10:38
@almas-x almas-x requested a review from a team as a code owner April 16, 2025 10:38
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.

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (3)

database/console/seeder_make_command.go:66

  • [nitpick] Consider adding a space after the comma in the error message for improved readability, e.g., "Register seeder failed, got error: %s".
ctx.Warning(fmt.Sprintf("Register seeder failed,got error: %s", err.Error()))

database/console/migration/migrate_make_command.go:79

  • [nitpick] Consider adding a space after the comma in the error message ("Register migration failed, got error: %s") to improve clarity.
ctx.Warning(fmt.Sprintf("Register migration failed,got error: %s", err.Error()))

mocks/database/migration/Migrator.go:33

  • Ensure that the mocked Create function consistently returns both a string and an error to avoid potential type conversion issues in different test cases.
if rf, ok := ret.Get(0).(func(string) (string, error)); ok {

@codecov
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.76%. Comparing base (f5ade0f) to head (c8e72f7).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1011      +/-   ##
==========================================
+ Coverage   70.72%   70.76%   +0.04%     
==========================================
  Files         170      170              
  Lines       11617    11635      +18     
==========================================
+ Hits         8216     8234      +18     
  Misses       3048     3048              
  Partials      353      353              

☔ 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.

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

database/console/migration/migrate_make_command.go:74

  • [nitpick] The migration struct name is generated by prepending 'm_' to fileName and converting it using Studly(), which may lead to inconsistent naming if fileName includes a dynamic timestamp. Consider using a dedicated migration name parameter to ensure consistent and predictable struct names.
structName := str.Of(fileName).Prepend("m_").Studly().String()

database/console/seeder_make_command.go:63

  • Ensure that the file 'database/kernel.go' exists and conforms to the expected format before applying modifications, as failing to verify the file's existence can lead to runtime issues during registration.
if err = modify.GoFile(path.Database("kernel.go")).
		Find(match.Imports()...).Modify(modify.AddImport(m.GetPackageImportPath())).
		Find(match.Seeders()...).Modify(modify.Register(fmt.Sprintf("&%s.%s{}", m.GetPackageName(), m.GetStructName()))).
		Apply(); err != nil {

Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

Nice

@almas-x almas-x requested a review from hwbrzzl April 17, 2025 05:13
Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

Great 👍

@almas-x almas-x merged commit 86e9312 into master Apr 17, 2025
13 checks passed
@almas-x almas-x deleted the almas/#649 branch April 17, 2025 07:50
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.

migration and seeder can be registered automatically when using commands create them

3 participants