profile
viewpoint

Ask questionsAllow database configuration/settings path to be specified for CLI commands

Describe the feature as you'd like to see it It should be possible to specify where to load settings from when running migrations, seeders, etc using the masonite-orm CLI

This would allow the ORM to be used/integrated in existing projects without having to rewrite the rest of the application to use the predefined configuration directory (config/database(.py) to avoid duplication of config/settings directories.

What do we currently have to do now? There are multiple ways to implement the loading itself but the simplest way might be adding another CLI option that allows you to specify the configuration directory.

Example command: masonite-orm migrate --directory=src/database/migrations --config=src/settings/database

Additional context Example class/import triggered by masonite-orm migrate that does not currently work if settings are not in the exact specified pypath and format. image

This will currently result in the following module import error

(venv) C:\Users\{USER}\Code\{PROJECT}\{REPO}>masonite-orm migrate -d=src\api\database

  ModuleNotFoundError

  No module named 'config'

  at ~\Code\EVA_AST\ast_new\venv\lib\site-packages\masoniteorm\migrations\Migration.py:27 in __init__
       23│         self.migration_directory = migration_directory
       24│         self.last_migrations_ran = []
       25│         self.command_class = command_class
       26│
    →  27│         from config.database import DB
       28│
       29│         DATABASES = DB.get_connection_details()
       30│
       31│         self.schema = Schema(

This is already available in orator image

- [ ] Is this a breaking change? Only if the existing import/path is not set as default

MasoniteFramework/orm

Answer questions josephmancuso

Yeah. You understand the problem we're trying to solve here lol. Can you open a PR for this?

useful!

Related questions

No questions were found.
source:https://uonfu.com/
answerer
Joseph Mancuso josephmancuso @MasoniteFramework Long Island, New York http://docs.masoniteproject.com Joseph Mancuso | Software Developer | Creator of the @MasoniteFramework
Github User Rank List