]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/mysqlschema.php
Always naming it 'plugin' is not good, it can easily confuse. So better name it
[quix0rs-gnu-social.git] / lib / mysqlschema.php
index c3d3501c74cff52f6018cc73ac8120be65970a75..f1fc0f46ecd5c600fa12c4d4e128387288718ac1 100644 (file)
@@ -271,7 +271,7 @@ class MysqlSchema extends Schema
     function endCreateTable($name, array $def)
     {
         $engine = $this->preferredEngine($def);
-        return ") ENGINE=$engine CHARACTER SET utf8 COLLATE utf8_bin";
+        return ") ENGINE=$engine CHARACTER SET utf8mb4 COLLATE utf8mb4_bin";
     }
     
     function preferredEngine($def)
@@ -298,6 +298,16 @@ class MysqlSchema extends Schema
         return "{$tableName}_{$columnName}_idx";
     }
 
+    /**
+     * MySQL doesn't take 'DROP CONSTRAINT', need to treat primary keys as
+     * if they were indexes here, but can use 'PRIMARY KEY' special name.
+     *
+     * @param array $phrase
+     */
+    function appendAlterDropPrimary(array &$phrase)
+    {
+        $phrase[] = 'DROP PRIMARY KEY';
+    }
 
     /**
      * MySQL doesn't take 'DROP CONSTRAINT', need to treat unique keys as
@@ -325,9 +335,10 @@ class MysqlSchema extends Schema
         if (strtolower($oldProps['ENGINE']) != strtolower($engine)) {
             $phrase[] = "ENGINE=$engine";
         }
-        if (strtolower($oldProps['TABLE_COLLATION']) != 'utf8_bin') {
-            $phrase[] = 'DEFAULT CHARSET=utf8';
-            $phrase[] = 'COLLATE=utf8_bin';
+        if (strtolower($oldProps['TABLE_COLLATION']) != 'utf8mb4_bin') {
+            $phrase[] = 'CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin';
+            $phrase[] = 'DEFAULT CHARACTER SET = utf8mb4';
+            $phrase[] = 'DEFAULT COLLATE = utf8mb4_bin';
         }
     }