feat: [#649] auto-register migration and seeder when created via CLI#1011
Merged
feat: [#649] auto-register migration and seeder when created via CLI#1011
Conversation
Contributor
There was a problem hiding this comment.
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 ReportAll modified and coverable lines are covered by tests ✅
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. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
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 {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📑 Description
Closes goravel/goravel#649
This change improves workflow efficiency by automatically registering migration and seeder files created via artisan
make:migrationandartisan make:seeder.These files are now injected into database/kernel.go, eliminating the need for manual inclusion and streamlining the setup process.
✅ Checks