Repository navigation
Fix make command stubs, register db:make:observer, fix db:make:model flags - #294
Open
claude-tmgbedu wants to merge 7 commits into
Open
claude-tmgbedu wants to merge 7 commits into
claude-tmgbedu wants to merge 7 commits into
Conversation
The generated observer imported Model from the uninstalled masoniteorm package, stubbed events that never fire and carried docstrings. It now imports from fastapi_startkit.masoniteorm.models and defines async handlers for the eight dispatched events in order. A test imports the generated file and dispatches every event.
The model stub imported Model from the uninstalled masoniteorm package, so every generated model failed to import. The observer command was never registered, so artisan could not run it; it is now db:make:observer, matching the other db:make commands, and DatabaseProvider registers it.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
--migration called the unregistered "migration" command. Both flags also failed because Cleo's call binds its arguments against the application definition, which takes the first word as the command name. Nested calls now pass the command name first.
…eanup # Conflicts: # docs/adr/AGENTS.md
…eanup # Conflicts: # fastapi_startkit/tests/masoniteorm/commands/test_make_commands.py
This is a bug fix, not a design decision; remove ADR 028 and its docs/adr/AGENTS.md index row while keeping the fixes and tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Generated observers and models didn't import, the observer generator couldn't be run, and
db:make:model --migration/--seederfailed.observer.stubModelfrommasoniteorm.models, which the framework doesn't install, so importing a generated observer raisedModuleNotFoundError. It now imports fromfastapi_startkit.masoniteorm.models.booted/booting/hydrating/hydrated, which never fire. It now has the eight events from Model lifecycle events, automatic timestamps and datetime casts #291, in dispatch order:saving,creating,updating,created,updated,saved,deleting,deleted. They areasync def <event>(self, <model>: Model) -> None, andobserve_eventsawaits them.model.stubdb:make:modelfailed to import. The import is fixed and the docstrings are gone.make:observerMakeObserverCommandwas exported but never registered. It is renameddb:make:observer, matchingdb:make:migrationanddb:make:model, andDatabaseProviderregisters it. The old nameobserverwas never reachable fromartisan, so nothing depended on it.db:make:model --migration/--seederBoth failed on 0.67.0:
--migrationnow callsdb:make:migration.call_command(name, arguments), which puts the command name first. Cleo'sCommand.callbinds its args against the application definition, whose first positional iscommand, so without the prefix the first argument was taken as the command name and lost. The fix stays inMakeModelCommandinstead of overridingcallon the core consoleCommand, because this is the only working caller.ADR 028 and its index row are updated (renumbered from 026, which is taken by #292; #293 has 027).
Validation
Model.observe_events.app.run("db:make:observer", "Order")works on an app booted withDatabaseProvider, the same pathartisanuses. It fails when the registration is removed.app.run("db:make:model", ...)with--migration,--migration --tableand--seedercreates the create/update migration and the seeder. All three fail without the fix.uvx fastapi-startkit init, against this branch's build:python artisan db:make:model Invoiceandpython artisan db:make:observer Invoicecreated files that both import.python artisan db:make:model Receipt --migration --seedercreated the model, migration and seeder, andpython artisan db:migrateapplied the migration.Not in this PR
db:migrate:fresh --seedanddb:migrate:refresh --seedcallseed:run, which doesn't exist (it'sdb:seed). The call has the same argument problem, and it runs insideasyncio.run, sodb:seedwould start a second event loop.db:migrate:refreshalso isn't registered. The fix needs the seeding restructured and new fixtures, which would push this PR past 10 files.🤖 Generated with Claude Code