From dcb0574c37003cccb6d09166ebe659280df2bb49 Mon Sep 17 00:00:00 2001 From: Robert Kujawa Date: Thu, 27 Apr 2023 07:38:06 -0600 Subject: [PATCH 1/2] Load migrations without the need to publish --- src/PaymentServiceProvider.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/PaymentServiceProvider.php b/src/PaymentServiceProvider.php index 0062108..735e267 100644 --- a/src/PaymentServiceProvider.php +++ b/src/PaymentServiceProvider.php @@ -10,9 +10,15 @@ class PaymentServiceProvider extends ServiceProvider { public function boot() { + if (! $this->app->runningInConsole()) { + return; + } + $this->registerPublishableAssets(); $this->registerCommands(); + + $this->registerMigrations(); } public function register() @@ -29,10 +35,6 @@ public function register() protected function registerPublishableAssets() { - if (! $this->app->runningInConsole()) { - return; - } - $this->publishes([ __DIR__ . '/database/migrations/2021_01_01_000000_create_base_payment_tables.php' => database_path('migrations/2021_01_01_000000_create_base_payment_tables.php'), ], 'payavel-migrations'); @@ -44,13 +46,14 @@ protected function registerPublishableAssets() protected function registerCommands() { - if (! $this->app->runningInConsole()) { - return; - } - $this->commands([ MakeProvider::class, Install::class, ]); } + + protected function registerMigrations() + { + $this->loadMigrationsFrom(__DIR__ . '/database/migrations'); + } } From a0c8d11569fe4d5540135646fe8e57628f95c8fc Mon Sep 17 00:00:00 2001 From: Robert Kujawa Date: Thu, 27 Apr 2023 10:13:55 -0600 Subject: [PATCH 2/2] Remove migration workarounds made in past --- src/Console/Commands/Install.php | 4 ---- tests/TestCase.php | 14 -------------- tests/Unit/BillableTraitTest.php | 17 ----------------- 3 files changed, 35 deletions(-) diff --git a/src/Console/Commands/Install.php b/src/Console/Commands/Install.php index eb6a9b4..7ab664d 100644 --- a/src/Console/Commands/Install.php +++ b/src/Console/Commands/Install.php @@ -53,10 +53,6 @@ class Install extends Command */ public function handle() { - if (! class_exists('CreateBasePaymentTables')) { - $this->call('vendor:publish', ['--provider' => 'Payavel\Checkout\PaymentServiceProvider', '--tag' => 'payavel-migrations']); - } - $this->installProviders(); $this->installMerchants(); diff --git a/tests/TestCase.php b/tests/TestCase.php index 8293f0c..3d61f6c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -32,20 +32,6 @@ protected function getEnvironmentSetUp($app) ]); } - /** - * Perform any work that should take place once the database has finished refreshing. - * - * @return void - */ - protected function afterRefreshingDatabase() - { - if (! class_exists('CreateBasePaymentTables')) { - $this->artisan('vendor:publish', ['--provider' => 'Payavel\Checkout\PaymentServiceProvider', '--tag' => 'payavel-migrations']); - - $this->artisan('migrate'); - } - } - /** * Setup the test environment. * diff --git a/tests/Unit/BillableTraitTest.php b/tests/Unit/BillableTraitTest.php index 9bb9044..1119f83 100644 --- a/tests/Unit/BillableTraitTest.php +++ b/tests/Unit/BillableTraitTest.php @@ -9,23 +9,6 @@ class BillableTraitTest extends TestCase { - /** - * Setup the test environment. - * - * @return void - */ - protected function setUp(): void - { - parent::setUp(); - - $this->artisan('vendor:publish', [ - '--provider' => 'Payavel\\Checkout\\PaymentServiceProvider', - '--tag' => 'payavel-migrations' - ]); - - $this->artisan('migrate'); - } - /** @test */ public function retrieve_billable_wallets() {