]> BookStack Code Mirror - bookstack/commitdiff
Added checks to use MyISAM if MySQL 5.5 is found
authorDan Brown <redacted>
Sat, 4 Jun 2016 15:32:57 +0000 (16:32 +0100)
committerDan Brown <redacted>
Sat, 4 Jun 2016 15:32:57 +0000 (16:32 +0100)
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

index 121607f6ad7fedde01e2af6accf5332b621d0fd4..4220809d56e5145e1be711392f618e066de59d9c 100644 (file)
@@ -12,8 +12,13 @@ class CreateBooksTable extends Migration
      */
     public function up()
     {
-        Schema::create('books', function (Blueprint $table) {
-           $table->engine = 'MyISAM';
+        $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';
+            
             $table->increments('id');
             $table->string('name');
             $table->string('slug')->indexed();
index 5e6e7e812ecd6486b739e23d7c74c9c8dd4fed9a..0a29d1087195024ba57bd82c4af036c6772882b0 100644 (file)
@@ -12,8 +12,13 @@ class CreatePagesTable extends Migration
      */
     public function up()
     {
-        Schema::create('pages', function (Blueprint $table) {
-           $table->engine = 'MyISAM';
+        $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';
+            
             $table->increments('id');
             $table->integer('book_id');
             $table->integer('chapter_id');
index 74594121fc2c425a39c87399812e6a68c8e7de8a..3ec414480773089f64823e2936f0656beae7e623 100644 (file)
@@ -12,8 +12,12 @@ class CreateChaptersTable extends Migration
      */
     public function up()
     {
-        Schema::create('chapters', function (Blueprint $table) {
-           $table->engine = 'MyISAM';
+        $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';
             $table->increments('id');
             $table->integer('book_id');
             $table->string('slug')->indexed();