From a5d0fa6fd34dd60c7c9660bebf0ea00641323371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Sat, 21 Sep 2024 00:22:22 +0000 Subject: [PATCH] Revert migrations --- ...4_replace_emoji_shortcuts_with_unicode.php | 101 ------------------ .../2018_09_15_041340_add_users_indices.php | 31 ------ ...8_09_15_041828_add_discussions_indices.php | 37 ------- 3 files changed, 169 deletions(-) delete mode 100644 extensions/emoji/migrations/2018_09_29_060444_replace_emoji_shortcuts_with_unicode.php delete mode 100644 framework/core/migrations/2018_09_15_041340_add_users_indices.php delete mode 100644 framework/core/migrations/2018_09_15_041828_add_discussions_indices.php diff --git a/extensions/emoji/migrations/2018_09_29_060444_replace_emoji_shortcuts_with_unicode.php b/extensions/emoji/migrations/2018_09_29_060444_replace_emoji_shortcuts_with_unicode.php deleted file mode 100644 index b5c025e511..0000000000 --- a/extensions/emoji/migrations/2018_09_29_060444_replace_emoji_shortcuts_with_unicode.php +++ /dev/null @@ -1,101 +0,0 @@ - function (Builder $schema) { - $emojioneToTwemojiMap = [ - '1f468-2764-1f468' => '1f468-200d-2764-fe0f-200d-1f468', - '1f469-2764-1f469' => '1f469-200d-2764-fe0f-200d-1f469', - '1f468-2764-1f48b-1f468' => '1f468-200d-2764-fe0f-200d-1f48b-200d-1f468', - '1f469-2764-1f48b-1f469' => '1f469-200d-2764-fe0f-200d-1f48b-200d-1f469', - '1f468-1f468-1f466' => '1f468-200d-1f468-200d-1f466', - '1f468-1f468-1f466-1f466' => '1f468-200d-1f468-200d-1f466-200d-1f466', - '1f468-1f468-1f467' => '1f468-200d-1f468-200d-1f467', - '1f468-1f468-1f467-1f466' => '1f468-200d-1f468-200d-1f467-200d-1f466', - '1f468-1f468-1f467-1f467' => '1f468-200d-1f468-200d-1f467-200d-1f467', - '1f468-1f469-1f466-1f466' => '1f468-200d-1f469-200d-1f466-200d-1f466', - '1f468-1f469-1f467' => '1f468-200d-1f469-200d-1f467', - '1f468-1f469-1f467-1f466' => '1f468-200d-1f469-200d-1f467-200d-1f466', - '1f468-1f469-1f467-1f467' => '1f468-200d-1f469-200d-1f467-200d-1f467', - '1f469-1f469-1f466' => '1f469-200d-1f469-200d-1f466', - '1f469-1f469-1f466-1f466' => '1f469-200d-1f469-200d-1f466-200d-1f466', - '1f469-1f469-1f467' => '1f469-200d-1f469-200d-1f467', - '1f469-1f469-1f467-1f466' => '1f469-200d-1f469-200d-1f467-200d-1f466', - '1f469-1f469-1f467-1f467' => '1f469-200d-1f469-200d-1f467-200d-1f467', - '1f441-1f5e8' => '1f441-200d-1f5e8', // as always PITA - '1f3f3-1f308' => '1f3f3-fe0f-200d-1f308', - - // https://github.com/twitter/twemoji/issues/192 - '1f91d-1f3fb' => '1f91d', - '1f91d-1f3fc' => '1f91d', - '1f91d-1f3fd' => '1f91d', - '1f91d-1f3fe' => '1f91d', - '1f91d-1f3ff' => '1f91d', - '1f93c-1f3fb' => '1f93c', - '1f93c-1f3fc' => '1f93c', - '1f93c-1f3fd' => '1f93c', - '1f93c-1f3fe' => '1f93c', - '1f93c-1f3ff' => '1f93c', - ]; - - $fromCodePoint = function ($code) { - $num = intval($code, 16); - - if ($num <= 0x7F) { - return chr($num); - } - - if ($num <= 0x7FF) { - return chr(($num >> 6) + 192).chr(($num & 63) + 128); - } - - if ($num <= 0xFFFF) { - return chr(($num >> 12) + 224).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128); - } - - return chr(($num >> 18) + 240).chr((($num >> 12) & 63) + 128).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128); - }; - - $convertEmojioneToTwemoji = function ($code) use ($emojioneToTwemojiMap) { - if (isset($emojioneToTwemojiMap[$code])) { - return $emojioneToTwemojiMap[$code]; - } - - return ltrim($code, '0'); - }; - - $posts = $schema->getConnection()->table('posts') - ->select('id', 'content') - ->where('content', 'like', '%cursor(); - - foreach ($posts as $post) { - $content = preg_replace_callback( - '/.+?<\/EMOJI>/', - function ($m) use ($convertEmojioneToTwemoji, $fromCodePoint) { - $code = $convertEmojioneToTwemoji($m[1]); - $codepoints = explode('-', $code); - - return implode('', array_map($fromCodePoint, $codepoints)); - }, - $post->content - ); - - $schema->getConnection()->table('posts') - ->where('id', $post->id) - ->update(['content' => $content]); - } - }, - - 'down' => function (Builder $schema) { - // not implemented - } -]; diff --git a/framework/core/migrations/2018_09_15_041340_add_users_indices.php b/framework/core/migrations/2018_09_15_041340_add_users_indices.php deleted file mode 100644 index 15a9d6931b..0000000000 --- a/framework/core/migrations/2018_09_15_041340_add_users_indices.php +++ /dev/null @@ -1,31 +0,0 @@ - function (Builder $schema) { - $schema->table('users', function (Blueprint $table) { - $table->index('joined_at'); - $table->index('last_seen_at'); - $table->index('discussion_count'); - $table->index('comment_count'); - }); - }, - - 'down' => function (Builder $schema) { - $schema->table('users', function (Blueprint $table) { - $table->dropIndex(['joined_at']); - $table->dropIndex(['last_seen_at']); - $table->dropIndex(['discussion_count']); - $table->dropIndex(['comment_count']); - }); - } -]; diff --git a/framework/core/migrations/2018_09_15_041828_add_discussions_indices.php b/framework/core/migrations/2018_09_15_041828_add_discussions_indices.php deleted file mode 100644 index 8a74b08d94..0000000000 --- a/framework/core/migrations/2018_09_15_041828_add_discussions_indices.php +++ /dev/null @@ -1,37 +0,0 @@ - function (Builder $schema) { - $schema->table('discussions', function (Blueprint $table) { - $table->index('last_posted_at'); - $table->index('last_posted_user_id'); - $table->index('created_at'); - $table->index('user_id'); - $table->index('comment_count'); - $table->index('participant_count'); - $table->index('hidden_at'); - }); - }, - - 'down' => function (Builder $schema) { - $schema->table('discussions', function (Blueprint $table) { - $table->dropIndex(['last_posted_at']); - $table->dropIndex(['last_posted_user_id']); - $table->dropIndex(['created_at']); - $table->dropIndex(['user_id']); - $table->dropIndex(['comment_count']); - $table->dropIndex(['participant_count']); - $table->dropIndex(['hidden_at']); - }); - } -];