Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple migrations-directories #342

Open
marcusrettig opened this issue Jun 19, 2023 · 2 comments
Open

Support multiple migrations-directories #342

marcusrettig opened this issue Jun 19, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@marcusrettig
Copy link

Is your feature request related to a problem? Please describe.
The plugin only considers migrations in the database/migrations directory. If migrations are spread out in several directories, e.g. when using Laravel Modules, some Model stubs are generated without @property definitions. This results in many false positive UndefinedMagicPropertyAssignment errors.

Describe the solution you'd like
First, a warning message would be nice when a table can't be found (here).

Second, a way to specify multiple directories for migrations would be nice. I'm not sure what would be the best way to do this.

Describe alternatives you've considered
Temporarily moving all migrations into database/migrations before running Psalm fixes the issue, but it is rather inconvenient.

Additional context
Our directory structure looks like this:

database/
    migrations/
modules/
    MobuleA/
        database/
            migrations/
    MobuleB/
        database/
            migrations/
@marcusrettig marcusrettig added the enhancement New feature or request label Jun 19, 2023
@Ar-Monta
Copy link

Ar-Monta commented Apr 3, 2024

Hello @marcusrettig
To support migrating from a specific migration directory you can customize your module's service provider by overriding boot() function and adding this line of code:
$this->loadMigrationsFrom("YOUR_SPECIFIC_MODULE_MIGRATIONS_DIRECTORY");

@alies-dev
Copy link
Collaborator

alies-dev commented Feb 17, 2025

hey @marcusrettig

Would for your case be acceptable to provide this list of directories via XML config. Example (psalm.xml partial):

...
 <plugins>
        <pluginClass class="Psalm\LaravelPlugin\Plugin">
            <migrationsPath>database/migrations</migrationsPath>
            <migrationsPath>modules/ModuleA/database/migrations</migrationsPath>
            <migrationsPath>modules/ModuleB/database/migrations</migrationsPath>
        </pluginClass>
    </plugins>
...

or do you prefer to get these paths in a runtime (if it's possible via public Laravel native API)? (the plugin inits an Application instance anyway)
?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants