Skip to content

[1.x] Make migrations publishable #81

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

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Facades/Pulse.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
* @method static \Laravel\Pulse\Pulse rememberUser(\Illuminate\Contracts\Auth\Authenticatable $user)
* @method static string css()
* @method static string js()
* @method static bool runsMigrations()
* @method static \Laravel\Pulse\Pulse ignoreMigrations()
* @method static bool registersRoutes()
* @method static \Laravel\Pulse\Pulse ignoreRoutes()
* @method static \Laravel\Pulse\Pulse handleExceptionsUsing(callable $callback)
Expand Down
23 changes: 0 additions & 23 deletions src/Pulse.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ class Pulse
*/
protected int|string|null $rememberedUserId = null;

/**
* Indicates if Pulse migrations will be run.
*/
protected bool $runsMigrations = true;

/**
* Indicates if Pulse routes will be registered.
*/
Expand Down Expand Up @@ -456,24 +451,6 @@ public function js(): string
return $content;
}

/**
* Determine if Pulse may run migrations.
*/
public function runsMigrations(): bool
{
return $this->runsMigrations;
}

/**
* Configure Pulse to not register its migrations.
*/
public function ignoreMigrations(): self
{
$this->runsMigrations = false;

return $this;
}

/**
* Determine if Pulse may register routes.
*/
Expand Down
18 changes: 4 additions & 14 deletions src/PulseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Http\Kernel as HttpKernel;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Queue\Events\Looping;
use Illuminate\Queue\Events\WorkerStopping;
use Illuminate\Routing\Router;
Expand Down Expand Up @@ -75,7 +74,6 @@ public function boot(): void
$this->listenForEvents();
$this->registerComponents();
$this->registerResources();
$this->registerMigrations();
$this->registerPublishing();
$this->registerCommands();
}
Expand Down Expand Up @@ -190,18 +188,6 @@ protected function registerResources(): void
$this->loadViewsFrom(__DIR__.'/../resources/views', 'pulse');
}

/**
* Register the package's migrations.
*/
protected function registerMigrations(): void
{
$this->callAfterResolving('migrator', function (Migrator $migrator, Application $app) {
if ($app->make(Pulse::class)->runsMigrations()) {
$migrator->path(__DIR__.'/../database/migrations');
}
});
}

/**
* Register the package's publishable resources.
*/
Expand All @@ -215,6 +201,10 @@ protected function registerPublishing(): void
$this->publishes([
__DIR__.'/../resources/views/dashboard.blade.php' => resource_path('views/vendor/pulse/dashboard.blade.php'),
], ['pulse', 'pulse-dashboard']);

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

Expand Down
1 change: 1 addition & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected function getPackageProviders($app): array

protected function defineDatabaseMigrations(): void
{
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->loadMigrationsFrom(__DIR__.'/migrations');
}

Expand Down