<commit_before><?php

/**
 *    Copyright 2016 ppy Pty. Ltd.
 *
 *    This file is part of osu!web. osu!web is distributed in the hopes of
 *    attracting more community contributions to the core ecosystem of osu!
 *
 *    osu!web is free software: you can redistribute it and/or modify
 *    it under the terms of the Affero GNU General Public License version 3
 *    as published by the Free Software Foundation.
 *
 *    osu!web is distributed WITHOUT ANY WARRANTY; without even the implied
 *    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *    See the GNU Affero General Public License for more details.
 *
 *    You should have received a copy of the GNU Affero General Public License
 *    along with osu!web.  If not, see <http://www.gnu.org/licenses/>.
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class ChatBaseTables extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $builder = Schema::connection('mysql-chat');

        $builder->create('channels', function (Blueprint $table) {
            $table->charset = 'latin1';

            $table->increments('channel_id');
            $column = $table->string('name', 50);
            $column->charset = 'utf8';
            $table->string('description', 256);
            $table->timestamp('creation_time')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->enum('type', ['PUBLIC', 'PRIVATE', 'MULTIPLAYER', 'SPECTATOR', 'TEMPORARY'])->default('TEMPORARY');
            $table->string('allowed_groups', 256)->nullable();

            $table->index('name', 'name');
            $table->index('creation_time', 'creation_time');
        });
        $this->setRowFormat('channels', 'DYNAMIC');

        $builder->create('messages', function (Blueprint $table) {
            $table->charset = 'utf8';

            $table->increments('message_id');
            $table->integer('user_id')->unsigned();
            $table->integer('channel_id')->unsigned();
            $table->string('content', 1024)->default('');
            $table->timestamp('timestamp')->default(DB::raw('CURRENT_TIMESTAMP'));

            $table->index(['channel_id', 'message_id'], 'channel_id');
            $table->index(['user_id', 'timestamp'], 'user_history');
        });
        $this->setRowFormat('messages', 'COMPRESSED');

        $builder->create('messages_private', function (Blueprint $table) {
            $table->charset = 'utf8';

            $table->increments('message_id');
            $table->integer('user_id')->unsigned();
            $table->integer('target_id')->unsigned();
            $table->string('content', 1024)->default('');
            $table->timestamp('timestamp')->default(DB::raw('CURRENT_TIMESTAMP'));

            $table->index('user_id', 'user_id');
        });
        DB::statement('ALTER TABLE `messages_private` DROP PRIMARY KEY, ADD PRIMARY KEY (`message_id`, `timestamp`)');
        $this->setRowFormat('messages_private', 'COMPRESSED');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        $builder = Schema::connection('mysql-chat');

        $builder->drop('channels');
        $builder->drop('messages');
        $builder->drop('messages_private');
    }
}
<commit_msg>Fix osu_chat migration<commit_after><?php

/**
 *    Copyright 2016 ppy Pty. Ltd.
 *
 *    This file is part of osu!web. osu!web is distributed in the hopes of
 *    attracting more community contributions to the core ecosystem of osu!
 *
 *    osu!web is free software: you can redistribute it and/or modify
 *    it under the terms of the Affero GNU General Public License version 3
 *    as published by the Free Software Foundation.
 *
 *    osu!web is distributed WITHOUT ANY WARRANTY; without even the implied
 *    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *    See the GNU Affero General Public License for more details.
 *
 *    You should have received a copy of the GNU Affero General Public License
 *    along with osu!web.  If not, see <http://www.gnu.org/licenses/>.
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class ChatBaseTables extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $builder = Schema::connection('mysql-chat');
        $connection = DB::connection('mysql-chat');

        $builder->create('channels', function (Blueprint $table) {
            $table->charset = 'utf8mb4';

            $table->increments('channel_id');
            $column = $table->string('name', 50);
            $column->charset = 'utf8mb4';
            $table->string('description', 256);
            $table->timestamp('creation_time')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->enum('type', ['Public', 'Private', 'Multiplayer', 'Spectator', 'Temporary'])->default('Temporary');
            $table->string('allowed_groups', 256)->nullable();

            $table->index('name', 'name');
            $table->index('creation_time', 'creation_time');
        });
        $this->setRowFormat($connection, 'channels', 'DYNAMIC');

        $builder->create('messages', function (Blueprint $table) {
            $table->charset = 'utf8mb4';

            $table->increments('message_id');
            $table->integer('user_id')->unsigned();
            $table->integer('channel_id')->unsigned();
            $table->string('content', 1024)->default('');
            $table->timestamp('timestamp')->default(DB::raw('CURRENT_TIMESTAMP'));

            $table->index(['channel_id', 'message_id'], 'channel_id');
            $table->index(['user_id', 'timestamp'], 'user_history');
        });
        $connection->statement('ALTER TABLE `messages` DROP PRIMARY KEY, ADD PRIMARY KEY (`message_id`, `timestamp`)');
        $this->setRowFormat($connection, 'messages', 'COMPRESSED');

        $builder->create('messages_private', function (Blueprint $table) {
            $table->charset = 'utf8mb4';

            $table->increments('message_id');
            $table->integer('user_id')->unsigned();
            $table->integer('target_id')->unsigned();
            $table->string('content', 1024)->default('');
            $table->timestamp('timestamp')->default(DB::raw('CURRENT_TIMESTAMP'));

            $table->index(['user_id', 'timestamp'], 'user_id');
        });
        $connection->statement('ALTER TABLE `messages_private` DROP PRIMARY KEY, ADD PRIMARY KEY (`message_id`, `timestamp`)');
        $this->setRowFormat($connection, 'messages_private', 'COMPRESSED');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        $builder = Schema::connection('mysql-chat');

        $builder->drop('channels');
        $builder->drop('messages');
        $builder->drop('messages_private');
    }

    private function setRowFormat($connection, $table, $format)
    {
        $connection->statement("ALTER TABLE `{$table}` ROW_FORMAT={$format};");
    }
}

{'fraction_non_alphanumeric': 0.16016226045600784, 'fraction_numerical': 0.007553503986571549, 'mean_word_length': 2.8502961766289716, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 98, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7484878', 'n_tokens_mistral': 2018, 'n_tokens_neox': 1935, 'n_words': 458}