summaryrefslogtreecommitdiffstats
path: root/application/migrations/021_change_charset.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-10-28 20:36:59 +0200
committerFlorian Pritz <bluewind@xinu.at>2017-10-28 20:36:59 +0200
commit99bf28fef1a5bb0f89919d1e5e722c9eace6826a (patch)
tree068e0425b000858a7820b0aeb53b0c5eb865b748 /application/migrations/021_change_charset.php
parent9a17c141f8acee118200fe70a6ae831e5bb4b002 (diff)
mysql: Enable full UTF8 support
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/migrations/021_change_charset.php')
-rw-r--r--application/migrations/021_change_charset.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/application/migrations/021_change_charset.php b/application/migrations/021_change_charset.php
new file mode 100644
index 000000000..20a8ce7f7
--- /dev/null
+++ b/application/migrations/021_change_charset.php
@@ -0,0 +1,27 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_change_charset extends CI_Migration {
+
+ public function up()
+ {
+ $prefix = $this->db->dbprefix;
+
+ if ($this->db->dbdriver == 'postgre') {
+ # nothing to do
+ } else {
+ $this->db->query('SET FOREIGN_KEY_CHECKS = 0');
+ foreach (['actions', 'apikeys', 'files', 'file_storage', 'multipaste', 'multipaste_file_map', 'profiles', 'users'] as $table) {
+ $this->db->query('
+ ALTER TABLE `'.$prefix.$table.'` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
+ ');
+ }
+ $this->db->query('SET FOREIGN_KEY_CHECKS = 1');
+ }
+ }
+
+ public function down()
+ {
+ throw new \exceptions\ApiException("migration/downgrade-not-supported", "downgrade not supported");
+ }
+}