Closed girardinsamuel closed 2 years ago
@josephmancuso what's your opinion ?
@girardinsamuel When we use the ORM in standalone way, should have some way to define a custom folder to models too?
Asking because the masonite-orm has its own configuration file. There's a way to use one place to configure models folder in config.py ( standalone orm ) or using it inside masonite framework?
The Approach one maybe will be useful to change between this two forms to use it.
MakeModel receiving the location in constructor: from config.py
or self.application
.
Didn't see this before.
I think this is the best solution:
Duplicate this command inside Masonite commands and don't register the command in ORMProvider => then we can do what we want.
I guess you're right, i find it always difficult to decide between duplication or not. We are often attracted by being DRY but that's not always a good thing (as we already talked about !).
python craft model Post
should create the file at location defined bymodels.location
binding.Problem
The issue here is that this config is defined in Masonite and the command is coming from masonite-orm.
Here are some solutions to address this issue :
Approach 1
Should we add an argument in ORMProvider when initializing MakeModelCommand ?
This would require to edit the MakeModelCommand init method to add this argument and use it when defined and when not defined use the directory option...
Approach 2
Duplicate this command inside Masonite commands and don't register the command in ORMProvider => then we can do what we want.
Approach 3
Duplicate this command inside Masonite commands and don't register the command in ORMProvider. But inherit the MakeModelCommand from masoniteorm.