Skip to content

Commit

Permalink
Bugfix: Conditionally load package migration if it has not been publi…
Browse files Browse the repository at this point in the history
…shed
  • Loading branch information
Monamoxie committed May 26, 2024
1 parent 122de1f commit ebf3433
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Providers/VocabMapperServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ public function register(): void
{

$this->mergeConfigFrom(dirname(__DIR__, 2) . '/config/vocab.php', 'vocab');
$this->loadMigrationsFrom(dirname(__DIR__, 2) . '/database/migrations');

if ($this->shouldLoadPackageMigration()) {
$this->loadMigrationsFrom(dirname(__DIR__, 2) . '/database/migrations');
}

$loader = AliasLoader::getInstance();
$loader->alias('VocabCollector', VocabCollector::class);
Expand Down
9 changes: 9 additions & 0 deletions src/Traits/VocabHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ public function getMigrationDirectory(): string

return sprintf('%s/%s', $main, $subDir);
}

public function shouldLoadPackageMigration(): bool
{
$migrationDir = $this->getMigrationDirectory();

return !is_dir($migrationDir) ||
!count(glob($migrationDir . '/*_create_vocabs_table.php')) ||
!count(glob($migrationDir . '/*_create_vocab_mappers_table.php'));
}
}

0 comments on commit ebf3433

Please sign in to comment.