<commit_before><?php

namespace Laravel\Passport\Console;

use Laravel\Passport\Client;
use Laravel\Passport\Passport;
use Illuminate\Console\Command;

class UUIDCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'passport:uuid';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Generate version 4 UUIDs for existing Passport clients';

    /**
     * Only show this command if Passport::useClientUUIDs is true
     *
     * @return null
     */
    public function __construct()
    {
        if (!Passport::$useClientUUIDs) {
            exit;
        }
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $this->comment('Generating version 4 UUIDs for Passport clients...');

        $clients = Client::where('uuid', null)->get();

        foreach($clients as $client) {
            $client->uuid = UUID::generate(4)->string;
            $client->save();
        }

        $this->line('✓ Done.');
    }
}<commit_msg>create  column in  if migrations were already run<commit_after><?php

namespace Laravel\Passport\Console;

use Laravel\Passport\Client;
use Laravel\Passport\Passport;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;

class UUIDCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'passport:uuid';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Generate version 4 UUIDs for existing Passport clients';

    /**
     * Only show this command if Passport::useClientUUIDs is true
     *
     * @return null
     */
    public function __construct()
    {
        parent::__construct();

        if (!Passport::$useClientUUIDs) {
            exit;
        }
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $this->comment('Checking for `uuid` column in `oauth_clients`...');
        if (!Schema::hasColumn('oauth_clients', 'uuid')) {
            Schema::table('oauth_clients', function(Blueprint $table) {
                $table->char('uuid', 36)->after('name')->nullable();
            });
            $this->line('✓ Created new column `uuid` in `oauth_clients`.');
        } else {
            $this->line('✓ OK.');
        }

        $this->comment('Generating version 4 UUIDs for Passport clients...');

        $clients = Client::where('uuid', null)->get();

        foreach($clients as $client) {
            $client->uuid = UUID::generate(4)->string;
            $client->save();
        }

        $this->line('✓ Done.');
    }
}
{'fraction_non_alphanumeric': 0.13521904104863747, 'fraction_numerical': 0.0027595722662987236, 'mean_word_length': 2.152173913043478, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '1654851', 'n_tokens_mistral': 840, 'n_tokens_neox': 841, 'n_words': 206}