Skip to content

Commit

Permalink
[1.x] Make migrations publishable (#81)
Browse files Browse the repository at this point in the history
* Make migrations publishable

Signed-off-by: Tobias Oitzinger <[email protected]>

* Remove implicit migration helpers

* Remove migration methods

---------

Signed-off-by: Tobias Oitzinger <[email protected]>
Co-authored-by: Tim MacDonald <[email protected]>
  • Loading branch information
toitzi and timacdonald authored Dec 5, 2023
1 parent 0683a75 commit e65fbbe
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 39 deletions.
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

0 comments on commit e65fbbe

Please sign in to comment.