Skip to content

NOW MANAGED ON CODEBERG

Migrations: Added prefix support to schema inspection

Dan Brownc221a00e1ed2
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) {