From c221a00e1ed2a01a66072f3f6a270464e12bab3c Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Tue, 19 Mar 2024 10:30:26 +0000 Subject: [PATCH] Migrations: Added prefix support to schema inspection --- .../migrations/2015_08_31_175240_add_search_indexes.php | 8 +++++--- .../migrations/2015_12_05_145049_fulltext_weighting.php | 8 +++++--- .../2017_03_19_091553_create_search_index_table.php | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/database/migrations/2015_08_31_175240_add_search_indexes.php b/database/migrations/2015_08_31_175240_add_search_indexes.php index 3382b2d54..4d58d9409 100644 --- a/database/migrations/2015_08_31_175240_add_search_indexes.php +++ b/database/migrations/2015_08_31_175240_add_search_indexes.php @@ -2,6 +2,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; return new class extends Migration @@ -26,9 +27,10 @@ return new class extends Migration public function down(): void { $sm = Schema::getConnection()->getDoctrineSchemaManager(); - $pages = $sm->introspectTable('pages'); - $books = $sm->introspectTable('books'); - $chapters = $sm->introspectTable('chapters'); + $prefix = DB::getTablePrefix(); + $pages = $sm->introspectTable($prefix . 'pages'); + $books = $sm->introspectTable($prefix . 'books'); + $chapters = $sm->introspectTable($prefix . 'chapters'); if ($pages->hasIndex('search')) { Schema::table('pages', function (Blueprint $table) { diff --git a/database/migrations/2015_12_05_145049_fulltext_weighting.php b/database/migrations/2015_12_05_145049_fulltext_weighting.php index 33163e854..b20c04520 100644 --- a/database/migrations/2015_12_05_145049_fulltext_weighting.php +++ b/database/migrations/2015_12_05_145049_fulltext_weighting.php @@ -2,6 +2,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; return new class extends Migration @@ -26,9 +27,10 @@ return new class extends Migration public function down(): void { $sm = Schema::getConnection()->getDoctrineSchemaManager(); - $pages = $sm->introspectTable('pages'); - $books = $sm->introspectTable('books'); - $chapters = $sm->introspectTable('chapters'); + $prefix = DB::getTablePrefix(); + $pages = $sm->introspectTable($prefix . 'pages'); + $books = $sm->introspectTable($prefix . 'books'); + $chapters = $sm->introspectTable($prefix . 'chapters'); if ($pages->hasIndex('name_search')) { Schema::table('pages', function (Blueprint $table) { diff --git a/database/migrations/2017_03_19_091553_create_search_index_table.php b/database/migrations/2017_03_19_091553_create_search_index_table.php index 71f93fa2d..56281741e 100644 --- a/database/migrations/2017_03_19_091553_create_search_index_table.php +++ b/database/migrations/2017_03_19_091553_create_search_index_table.php @@ -2,6 +2,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; return new class extends Migration @@ -25,9 +26,10 @@ return new class extends Migration }); $sm = Schema::getConnection()->getDoctrineSchemaManager(); - $pages = $sm->introspectTable('pages'); - $books = $sm->introspectTable('books'); - $chapters = $sm->introspectTable('chapters'); + $prefix = DB::getTablePrefix(); + $pages = $sm->introspectTable($prefix . 'pages'); + $books = $sm->introspectTable($prefix . 'books'); + $chapters = $sm->introspectTable($prefix . 'chapters'); if ($pages->hasIndex('search')) { Schema::table('pages', function (Blueprint $table) {