From 0bf464b80d7c2506f3eb9e24650e1aeb58e23825 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 21 Apr 2023 15:32:08 +0200 Subject: [PATCH] Filter migration files in create RLS policies command --- src/Commands/CreateRLSPoliciesForTenantTables.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Commands/CreateRLSPoliciesForTenantTables.php b/src/Commands/CreateRLSPoliciesForTenantTables.php index 204c704c..529f90a1 100644 --- a/src/Commands/CreateRLSPoliciesForTenantTables.php +++ b/src/Commands/CreateRLSPoliciesForTenantTables.php @@ -28,11 +28,15 @@ class CreateRLSPoliciesForTenantTables extends Command protected function getTenantTables(): array { + $files = array_filter(File::files('./database/migrations/tenant'), function (SplFileInfo $migration) { + return str($migration)->contains('create_'); + }); + return array_map(function (SplFileInfo $migration) { return str($migration->getFilename()) ->after('create_') ->before('_table') ->toString(); - }, File::files('./database/migrations/tenant')); + }, $files); } }