Skip to content

Commit 97abe9a

Browse files
authored
Merge pull request #1 from MichalGallovic/master
Fix migration publishing
2 parents 356f812 + 79e2d1f commit 97abe9a

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/BatchNotificationsServiceProvider.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,24 @@ class BatchNotificationsServiceProvider extends ServiceProvider
1313
*/
1414
public function boot()
1515
{
16-
if ($this->app->runningInConsole()) {
17-
$this->publishes([
18-
__DIR__.'/../migrations/2018_09_04_205640_create_batch_notification_tables.php' => base_path('database/migrations'),
19-
]);
16+
$time = time();
2017

21-
$this->commands([
22-
Console\DispatchBatchNotifications::class
23-
]);
18+
if (!class_exists('CreateBatchNotificationTables')) {
19+
$migrationFileName = $this->getMigrationFilename('create_batch_notification_tables', $time);
20+
$this->publishes([
21+
__DIR__.'/../migrations/2018_09_04_205640_create_batch_notification_tables.php' => $migrationFileName,
22+
], 'migrations');
2423
}
24+
25+
$this->commands([
26+
Console\DispatchBatchNotifications::class
27+
]);
28+
}
29+
30+
protected function getMigrationFileName($migrationName, $time)
31+
{
32+
$timestamp = date('Y_m_d_His', $time);
33+
34+
return $this->app->databasePath() . "/migrations/{$timestamp}_{$migrationName}.php";
2535
}
2636
}

0 commit comments

Comments
 (0)