<commit_before><?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;

return [
    'up' => function (Builder $schema) {
        // in case someone updates from really old flagrow/byobu version, set is_private to 1 on private discussions
        $connection = $schema->getConnection();

        $ids = $connection->table('recipients')
            ->select('discussion_id')
            ->groupBy('discussion_id')
            ->get();

        $connection->table('discussions')
            ->whereIn('id', collect($ids)->pluck('discussion_id')->all())
            ->update(['is_private' => 1]);

        // stop if migrating from flagrow/byobu
        if ($schema->getConnection()->table('migrations')->whereExtension('flagrow-byobu')->exists()) {
            return;
        }

        $schema->create('recipients', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('discussion_id')->unsigned()->nullable();
            $table->integer('group_id')->unsigned()->nullable()->after('user_id');
            $table->integer('user_id')->unsigned();
            $table->timestamps();
            $table->timestamp('removed_at')->nullable();

            $table->foreign('discussion_id')
                ->references('id')
                ->on('discussions')
                ->onDelete('cascade');
            $table->foreign('user_id')
                ->references('id')
                ->on('users')
                ->onDelete('cascade');
            $table->foreign('group_id')
                ->references('id')
                ->on('groups')
                ->onDelete('cascade');
        });
    },
    'down' => function (Builder $schema) {
        $schema->drop('recipients');
    },
];<commit_msg>fixed when first installing byobu<commit_after><?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;

return [
    'up' => function (Builder $schema) {
        // in case someone updates from really old flagrow/byobu version, set is_private to 1 on private discussions
        $connection = $schema->getConnection();

        if ($connection->getSchemaBuilder()->hasTable('recipients')) {
            $ids = $connection->table('recipients')
                ->select('discussion_id')
                ->groupBy('discussion_id')
                ->get();

            $connection->table('discussions')
                ->whereIn('id', collect($ids)->pluck('discussion_id')->all())
                ->update(['is_private' => 1]);
        }

        // stop if migrating from flagrow/byobu
        if ($schema->getConnection()->table('migrations')->whereExtension('flagrow-byobu')->exists()) {
            return;
        }

        $schema->create('recipients', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('discussion_id')->unsigned()->nullable();
            $table->integer('user_id')->unsigned();
            $table->integer('group_id')->unsigned()->nullable();
            $table->timestamps();
            $table->timestamp('removed_at')->nullable();

            $table->foreign('discussion_id')
                ->references('id')
                ->on('discussions')
                ->onDelete('cascade');
            $table->foreign('user_id')
                ->references('id')
                ->on('users')
                ->onDelete('cascade');
            $table->foreign('group_id')
                ->references('id')
                ->on('groups')
                ->onDelete('cascade');
        });
    },
    'down' => function (Builder $schema) {
        $schema->drop('recipients');
    },
];
{'fraction_non_alphanumeric': 0.17570144374829746, 'fraction_numerical': 0.001089621356578589, 'mean_word_length': 2.0753768844221105, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 92, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5446619', 'n_tokens_mistral': 996, 'n_tokens_neox': 946, 'n_words': 152}