mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 15:34:04 +00:00
Use Schema::getAllTables() instead of the migration file names
This commit is contained in:
parent
91936bc5ab
commit
2d75f185b8
1 changed files with 3 additions and 11 deletions
|
|
@ -6,8 +6,7 @@ namespace Stancl\Tenancy\Commands;
|
|||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRLSPoliciesForTenantTables extends Command
|
||||
{
|
||||
|
|
@ -28,15 +27,8 @@ class CreateRLSPoliciesForTenantTables extends Command
|
|||
|
||||
protected function getTenantTables(): array
|
||||
{
|
||||
$files = array_filter(File::files('./database/migrations/tenant'), function (SplFileInfo $migration) {
|
||||
return str($migration->getFilename())->contains('create_');
|
||||
});
|
||||
$tables = array_map(fn ($table) => $table->tablename, Schema::getAllTables());
|
||||
|
||||
return array_map(function (SplFileInfo $migration) {
|
||||
return str($migration->getFilename())
|
||||
->after('create_')
|
||||
->before('_table')
|
||||
->toString();
|
||||
}, $files);
|
||||
return array_filter($tables, fn ($table) => Schema::hasColumn($table, config('tenancy.models.tenant_key_column')));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue