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

Automatically merge/load config and migrations #368

Open
tobytwigger opened this issue Feb 22, 2020 · 0 comments
Open

Automatically merge/load config and migrations #368

tobytwigger opened this issue Feb 22, 2020 · 0 comments

Comments

@tobytwigger
Copy link

tobytwigger commented Feb 22, 2020

I'm trying to use the revisionable package in another package I'm developing. I'm running into a problem because revisionable requires the config and migrations to be published before it can work.

Since revisionable is running in a package environment, I'm having to override the default service provider, copy the migrations/config to my package and merge them from there since the vendor folder location (i.e. location of the migrations and config in revisionable) isn't constant. This means that there are now two copies of the config and migrations, and any updates won't be reflected in the package.

If we were to call mergeConfigFrom() in the revisionable Service Provider, revisionable would still work even without publishing the config. This also won't affect any old versions since the config is merged.

public function boot()
    {
        $this->publishes([
            __DIR__ . '/../../config/revisionable.php' => config_path('revisionable.php'),
        ], 'config');
        $this->mergeConfigFrom(__DIR__ . '/../../config/revisionable.php', 'revisionable');

        $this->publishes([
            __DIR__ . '/../../migrations/' => database_path('migrations'),
        ], 'migrations');

    }

When migrations are loaded through loadMigrationsFrom(), it can cause problems if you've also published the migrations. We could get around this by not loading them by default, thus encouraging users to publish their own migrations as expected, but allow them to be loaded by setting 'load_migrations' (or similar) in the config to true?

These changes will then allow this package to be used within other packages without affecting current users of the package.

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

No branches or pull requests

1 participant