]> BookStack Code Mirror - bookstack/commitdiff
Removed old fulltext indexes from migrations
authorDan Brown <redacted>
Sat, 22 Sep 2018 23:30:48 +0000 (00:30 +0100)
committerDan Brown <redacted>
Sat, 22 Sep 2018 23:30:48 +0000 (00:30 +0100)
Prevents forcing of MyISAM for some databases
Removed old code to add indexes and added checks for existing indexes before removal.
Should still allow upgrades, rollbacks to old bookstack versions may be funky but
should not be high use-case.

composer.json
composer.lock
database/migrations/2015_07_12_114933_create_books_table.php
database/migrations/2015_07_12_190027_create_pages_table.php
database/migrations/2015_07_27_172342_create_chapters_table.php
database/migrations/2015_08_31_175240_add_search_indexes.php
database/migrations/2015_12_05_145049_fulltext_weighting.php
database/migrations/2017_03_19_091553_create_search_index_table.php

index 318dbb3a631596370c636160896fc26660c69389..3c372da63151d0be3c1050afde638af73b898ef2 100644 (file)
@@ -22,7 +22,8 @@
         "socialiteproviders/okta": "^1.0",
         "socialiteproviders/gitlab": "^3.0",
         "socialiteproviders/twitch": "^3.0",
-        "socialiteproviders/discord": "^2.0"
+        "socialiteproviders/discord": "^2.0",
+        "doctrine/dbal": "^2.5"
     },
     "require-dev": {
         "filp/whoops": "~2.0",
index 51fde846adca0417ef78f5ec2daac65d550c1493..6a92409dd9d8fcc175afafade2d8311a750e4c1c 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "b98be6702f1293174f785f99895e798b",
+    "content-hash": "eae00f50d183bb224c934683b06e8f9c",
     "packages": [
         {
             "name": "aws/aws-sdk-php",
             ],
             "time": "2014-05-19T10:25:02+00:00"
         },
+        {
+            "name": "doctrine/annotations",
+            "version": "v1.4.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/doctrine/annotations.git",
+                "reference": "54cacc9b81758b14e3ce750f205a393d52339e97"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97",
+                "reference": "54cacc9b81758b14e3ce750f205a393d52339e97",
+                "shasum": ""
+            },
+            "require": {
+                "doctrine/lexer": "1.*",
+                "php": "^5.6 || ^7.0"
+            },
+            "require-dev": {
+                "doctrine/cache": "1.*",
+                "phpunit/phpunit": "^5.7"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.4.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Roman Borschel",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Benjamin Eberlei",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Guilherme Blanco",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Jonathan Wage",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Johannes Schmitt",
+                    "email": "[email protected]"
+                }
+            ],
+            "description": "Docblock Annotations Parser",
+            "homepage": "http://www.doctrine-project.org",
+            "keywords": [
+                "annotations",
+                "docblock",
+                "parser"
+            ],
+            "time": "2017-02-24T16:22:25+00:00"
+        },
+        {
+            "name": "doctrine/cache",
+            "version": "v1.6.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/doctrine/cache.git",
+                "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/doctrine/cache/zipball/eb152c5100571c7a45470ff2a35095ab3f3b900b",
+                "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b",
+                "shasum": ""
+            },
+            "require": {
+                "php": "~5.5|~7.0"
+            },
+            "conflict": {
+                "doctrine/common": ">2.2,<2.4"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~4.8|~5.0",
+                "predis/predis": "~1.0",
+                "satooshi/php-coveralls": "~0.6"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.6.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Roman Borschel",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Benjamin Eberlei",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Guilherme Blanco",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Jonathan Wage",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Johannes Schmitt",
+                    "email": "[email protected]"
+                }
+            ],
+            "description": "Caching library offering an object-oriented API for many cache backends",
+            "homepage": "http://www.doctrine-project.org",
+            "keywords": [
+                "cache",
+                "caching"
+            ],
+            "time": "2017-07-22T12:49:21+00:00"
+        },
+        {
+            "name": "doctrine/collections",
+            "version": "v1.4.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/doctrine/collections.git",
+                "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/doctrine/collections/zipball/1a4fb7e902202c33cce8c55989b945612943c2ba",
+                "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^5.6 || ^7.0"
+            },
+            "require-dev": {
+                "doctrine/coding-standard": "~0.1@dev",
+                "phpunit/phpunit": "^5.7"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.3.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-0": {
+                    "Doctrine\\Common\\Collections\\": "lib/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Roman Borschel",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Benjamin Eberlei",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Guilherme Blanco",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Jonathan Wage",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Johannes Schmitt",
+                    "email": "[email protected]"
+                }
+            ],
+            "description": "Collections Abstraction library",
+            "homepage": "http://www.doctrine-project.org",
+            "keywords": [
+                "array",
+                "collections",
+                "iterator"
+            ],
+            "time": "2017-01-03T10:49:41+00:00"
+        },
+        {
+            "name": "doctrine/common",
+            "version": "v2.7.3",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/doctrine/common.git",
+                "reference": "4acb8f89626baafede6ee5475bc5844096eba8a9"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/doctrine/common/zipball/4acb8f89626baafede6ee5475bc5844096eba8a9",
+                "reference": "4acb8f89626baafede6ee5475bc5844096eba8a9",
+                "shasum": ""
+            },
+            "require": {
+                "doctrine/annotations": "1.*",
+                "doctrine/cache": "1.*",
+                "doctrine/collections": "1.*",
+                "doctrine/inflector": "1.*",
+                "doctrine/lexer": "1.*",
+                "php": "~5.6|~7.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^5.4.6"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.7.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Doctrine\\Common\\": "lib/Doctrine/Common"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Roman Borschel",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Benjamin Eberlei",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Guilherme Blanco",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Jonathan Wage",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Johannes Schmitt",
+                    "email": "[email protected]"
+                }
+            ],
+            "description": "Common Library for Doctrine projects",
+            "homepage": "http://www.doctrine-project.org",
+            "keywords": [
+                "annotations",
+                "collections",
+                "eventmanager",
+                "persistence",
+                "spl"
+            ],
+            "time": "2017-07-22T08:35:12+00:00"
+        },
+        {
+            "name": "doctrine/dbal",
+            "version": "v2.5.13",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/doctrine/dbal.git",
+                "reference": "729340d8d1eec8f01bff708e12e449a3415af873"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/doctrine/dbal/zipball/729340d8d1eec8f01bff708e12e449a3415af873",
+                "reference": "729340d8d1eec8f01bff708e12e449a3415af873",
+                "shasum": ""
+            },
+            "require": {
+                "doctrine/common": ">=2.4,<2.8-dev",
+                "php": ">=5.3.2"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "4.*",
+                "symfony/console": "2.*||^3.0"
+            },
+            "suggest": {
+                "symfony/console": "For helpful console commands such as SQL execution and import of files."
+            },
+            "bin": [
+                "bin/doctrine-dbal"
+            ],
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.5.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-0": {
+                    "Doctrine\\DBAL\\": "lib/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Roman Borschel",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Benjamin Eberlei",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Guilherme Blanco",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Jonathan Wage",
+                    "email": "[email protected]"
+                }
+            ],
+            "description": "Database Abstraction Layer",
+            "homepage": "http://www.doctrine-project.org",
+            "keywords": [
+                "database",
+                "dbal",
+                "persistence",
+                "queryobject"
+            ],
+            "time": "2017-07-22T20:44:48+00:00"
+        },
         {
             "name": "doctrine/inflector",
             "version": "v1.2.0",
     "prefer-lowest": false,
     "platform": {
         "php": ">=7.0.0",
-        "ext-tidy": "*"
+        "ext-tidy": "*",
+        "ext-dom": "*"
     },
     "platform-dev": [],
     "platform-overrides": {
index 4220809d56e5145e1be711392f618e066de59d9c..51fb55c48547f86be43d0929b8d44d414c7e40af 100644 (file)
@@ -12,13 +12,7 @@ class CreateBooksTable extends Migration
      */
     public function up()
     {
-        $pdo = \DB::connection()->getPdo();
-        $mysqlVersion = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION);
-        $requiresISAM = strpos($mysqlVersion, '5.5') === 0;
-
-        Schema::create('books', function (Blueprint $table) use ($requiresISAM) {
-               if($requiresISAM) $table->engine = 'MyISAM';
-            
+        Schema::create('books', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name');
             $table->string('slug')->indexed();
index 0a29d1087195024ba57bd82c4af036c6772882b0..7a1dcec0e88d7e1f616ff010cff1e3d7a36e5636 100644 (file)
@@ -12,13 +12,9 @@ class CreatePagesTable extends Migration
      */
     public function up()
     {
-        $pdo = \DB::connection()->getPdo();
-        $mysqlVersion = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION);
-        $requiresISAM = strpos($mysqlVersion, '5.5') === 0;
 
-        Schema::create('pages', function (Blueprint $table) use ($requiresISAM) {
-            if($requiresISAM) $table->engine = 'MyISAM';
-            
+
+        Schema::create('pages', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('book_id');
             $table->integer('chapter_id');
index 3ec414480773089f64823e2936f0656beae7e623..7974759f26e343f2c75051917ecbfa85324930cd 100644 (file)
@@ -12,12 +12,7 @@ class CreateChaptersTable extends Migration
      */
     public function up()
     {
-        $pdo = \DB::connection()->getPdo();
-        $mysqlVersion = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION);
-        $requiresISAM = strpos($mysqlVersion, '5.5') === 0;
-
-        Schema::create('chapters', function (Blueprint $table) use ($requiresISAM) {
-            if($requiresISAM) $table->engine = 'MyISAM';
+        Schema::create('chapters', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('book_id');
             $table->string('slug')->indexed();
index 127f69d281415fccc24d6cd10e3d8b452a21b495..497f88adde27ede97761cdb800fa5d6225b1deb6 100644 (file)
@@ -12,10 +12,13 @@ class AddSearchIndexes extends Migration
      */
     public function up()
     {
-        $prefix = DB::getTablePrefix();
-        DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT search(name, text)");
-        DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)");
-        DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)");
+        // This was removed for v0.24 since these indexes are removed anyway
+        // and will cause issues for db engines that don't support such indexes.
+
+//        $prefix = DB::getTablePrefix();
+//        DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT search(name, text)");
+//        DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)");
+//        DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)");
     }
 
     /**
@@ -25,14 +28,28 @@ class AddSearchIndexes extends Migration
      */
     public function down()
     {
-        Schema::table('pages', function(Blueprint $table) {
-            $table->dropIndex('search');
-        });
-        Schema::table('books', function(Blueprint $table) {
-            $table->dropIndex('search');
-        });
-        Schema::table('chapters', function(Blueprint $table) {
-            $table->dropIndex('search');
-        });
+        $sm = Schema::getConnection()->getDoctrineSchemaManager();
+        $pages = $sm->listTableDetails('pages');
+        $books = $sm->listTableDetails('books');
+        $chapters = $sm->listTableDetails('chapters');
+
+        if ($pages->hasIndex('search')) {
+            Schema::table('pages', function(Blueprint $table) {
+                $table->dropIndex('search');
+            });
+        }
+
+        if ($books->hasIndex('search')) {
+            Schema::table('books', function(Blueprint $table) {
+                $table->dropIndex('search');
+            });
+        }
+
+        if ($chapters->hasIndex('search')) {
+            Schema::table('chapters', function(Blueprint $table) {
+                $table->dropIndex('search');
+            });
+        }
+
     }
 }
index 99813138764893f34571512225d07bf5d2fa9d13..2e884b55c6af0d72e419ef1c41c6a6c52bf4839b 100644 (file)
@@ -12,10 +12,13 @@ class FulltextWeighting extends Migration
      */
     public function up()
     {
-        $prefix = DB::getTablePrefix();
-        DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)");
-        DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)");
-        DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)");
+        // This was removed for v0.24 since these indexes are removed anyway
+        // and will cause issues for db engines that don't support such indexes.
+
+//        $prefix = DB::getTablePrefix();
+//        DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)");
+//        DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)");
+//        DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)");
     }
 
     /**
@@ -25,14 +28,27 @@ class FulltextWeighting extends Migration
      */
     public function down()
     {
-        Schema::table('pages', function(Blueprint $table) {
-            $table->dropIndex('name_search');
-        });
-        Schema::table('books', function(Blueprint $table) {
-            $table->dropIndex('name_search');
-        });
-        Schema::table('chapters', function(Blueprint $table) {
-            $table->dropIndex('name_search');
-        });
+        $sm = Schema::getConnection()->getDoctrineSchemaManager();
+        $pages = $sm->listTableDetails('pages');
+        $books = $sm->listTableDetails('books');
+        $chapters = $sm->listTableDetails('chapters');
+
+        if ($pages->hasIndex('name_search')) {
+            Schema::table('pages', function(Blueprint $table) {
+                $table->dropIndex('name_search');
+            });
+        }
+
+        if ($books->hasIndex('name_search')) {
+            Schema::table('books', function(Blueprint $table) {
+                $table->dropIndex('name_search');
+            });
+        }
+
+        if ($chapters->hasIndex('name_search')) {
+            Schema::table('chapters', function(Blueprint $table) {
+                $table->dropIndex('name_search');
+            });
+        }
     }
 }
index 32c6a09e1c7de3f5fa617717866b4de6abfe7780..edffb445c941eec2a86c1bafa874beea7f46d51d 100644 (file)
@@ -26,19 +26,31 @@ class CreateSearchIndexTable extends Migration
             $table->index('score');
         });
 
-        // Drop search indexes
-        Schema::table('pages', function(Blueprint $table) {
-            $table->dropIndex('search');
-            $table->dropIndex('name_search');
-        });
-        Schema::table('books', function(Blueprint $table) {
-            $table->dropIndex('search');
-            $table->dropIndex('name_search');
-        });
-        Schema::table('chapters', function(Blueprint $table) {
-            $table->dropIndex('search');
-            $table->dropIndex('name_search');
-        });
+        $sm = Schema::getConnection()->getDoctrineSchemaManager();
+        $pages = $sm->listTableDetails('pages');
+        $books = $sm->listTableDetails('books');
+        $chapters = $sm->listTableDetails('chapters');
+
+        if ($pages->hasIndex('search')) {
+            Schema::table('pages', function(Blueprint $table) {
+                $table->dropIndex('search');
+                $table->dropIndex('name_search');
+            });
+        }
+
+        if ($books->hasIndex('search')) {
+            Schema::table('books', function(Blueprint $table) {
+                $table->dropIndex('search');
+                $table->dropIndex('name_search');
+            });
+        }
+
+        if ($chapters->hasIndex('search')) {
+            Schema::table('chapters', function(Blueprint $table) {
+                $table->dropIndex('search');
+                $table->dropIndex('name_search');
+            });
+        }
 
         app(\BookStack\Services\SearchService::class)->indexAllEntities();
     }
@@ -50,14 +62,17 @@ class CreateSearchIndexTable extends Migration
      */
     public function down()
     {
-        $prefix = DB::getTablePrefix();
-        DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT search(name, text)");
-        DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)");
-        DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)");
-        DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)");
-        DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)");
-        DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)");
+        // This was removed for v0.24 since these indexes are removed anyway
+        // and will cause issues for db engines that don't support such indexes.
 
+//        $prefix = DB::getTablePrefix();
+//        DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT search(name, text)");
+//        DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)");
+//        DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)");
+//        DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)");
+//        DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)");
+//        DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)");
+        
         Schema::dropIfExists('search_terms');
     }
 }