<commit_before><?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class MakeLakeUidPrimaryKeyForTermsAndCategories extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // terms
        Schema::table('terms', function (Blueprint $table) {
            $table->dropColumn('citi_id');
            $table->primary('lake_uid');
        });

        // categories
        Schema::table('categories', function (Blueprint $table) {
            $table->dropColumn('citi_id');
            $table->primary('lake_uid');
        });

        // artwork_category
        Schema::table('artwork_category', function(Blueprint $table) {
            $table->string('category_lake_uid')->nullable()->index();
        });

        DB::table('artwork_category')->update([
            'category_lake_uid' => DB::raw('\'PC-\' || category_citi_id')
        ]);

        Schema::table('artwork_category', function (Blueprint $table) {
            $table->dropColumn('category_citi_id');
        });

        // asset_category
        Schema::table('asset_category', function(Blueprint $table) {
            $table->string('category_lake_uid')->nullable()->index();
        });

        DB::table('asset_category')->update([
            'category_lake_uid' => DB::raw('\'PC-\' || category_citi_id')
        ]);

        Schema::table('asset_category', function (Blueprint $table) {
            $table->dropColumn('category_citi_id');
        });

        // category_place
        Schema::table('category_place', function(Blueprint $table) {
            $table->string('category_lake_uid')->nullable()->index();
        });

        DB::table('category_place')->update([
            'category_lake_uid' => DB::raw('\'PC-\' ||  category_citi_id')
        ]);

        Schema::table('category_place', function (Blueprint $table) {
            $table->dropColumn('category_citi_id');
        });

        // artwork_term
        Schema::table('artwork_term', function(Blueprint $table) {
            $table->string('term_lake_uid')->after('artwork_citi_id')->nullable()->index();
        });

        DB::table('artwork_term')->update([
            'term_lake_uid' => DB::raw('\'TM-\' || term_citi_id')
        ]);

        Schema::table('artwork_term', function (Blueprint $table) {
            $table->dropColumn('term_citi_id');
        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {

        // terms
        Schema::table('terms', function (Blueprint $table) {
            $table->dropPrimary();
            $table->integer('citi_id')->first();
        });

        DB::table('terms')->update([
            'citi_id' => DB::raw('substr(lake_uid FROM 4)')
        ]);

        Schema::table('terms', function (Blueprint $table) {
            $table->primary('citi_id');
        });

        // categories
        Schema::table('categories', function (Blueprint $table) {
            $table->dropPrimary();
            $table->integer('citi_id')->first();
        });

        DB::table('categories')->update([
            'citi_id' => DB::raw('substr(lake_uid FROM 4)')
        ]);

        Schema::table('categories', function (Blueprint $table) {
            $table->primary('citi_id');
        });

        // artwork_category
        Schema::table('artwork_category', function (Blueprint $table) {
            $table->integer('category_citi_id');
        });

        DB::table('artwork_category')->update([
            'category_citi_id' => DB::raw('substr(category_lake_uid FROM 4)')
        ]);

        Schema::table('artwork_category', function (Blueprint $table) {
            $table->dropColumn('category_lake_uid');
        });
<commit_msg>Update Category `parent_id` to use lake_uid<commit_after><?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class MakeLakeUidPrimaryKeyForTermsAndCategories extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // terms
        Schema::table('terms', function (Blueprint $table) {
            $table->dropColumn('citi_id');
            $table->primary('lake_uid');
        });

        // categories
        Schema::table('categories', function (Blueprint $table) {
            $table->dropColumn('citi_id');
            $table->primary('lake_uid');
            $table->string('parent_id')->index()->change();
        });

        DB::table('categories')->update([
            'parent_id' => DB::raw('\'PC-\' || parent_id')
        ]);

        // artwork_category
        Schema::table('artwork_category', function(Blueprint $table) {
            $table->string('category_lake_uid')->nullable()->index();
        });

        DB::table('artwork_category')->update([
            'category_lake_uid' => DB::raw('\'PC-\' || category_citi_id')
        ]);

        Schema::table('artwork_category', function (Blueprint $table) {
            $table->dropColumn('category_citi_id');
        });

        // asset_category
        Schema::table('asset_category', function(Blueprint $table) {
            $table->string('category_lake_uid')->nullable()->index();
        });

        DB::table('asset_category')->update([
            'category_lake_uid' => DB::raw('\'PC-\' || category_citi_id')
        ]);

        Schema::table('asset_category', function (Blueprint $table) {
            $table->dropColumn('category_citi_id');
        });

        // category_place
        Schema::table('category_place', function(Blueprint $table) {
            $table->string('category_lake_uid')->nullable()->index();
        });

        DB::table('category_place')->update([
            'category_lake_uid' => DB::raw('\'PC-\' ||  category_citi_id')
        ]);

        Schema::table('category_place', function (Blueprint $table) {
            $table->dropColumn('category_citi_id');
        });

        // artwork_term
        Schema::table('artwork_term', function(Blueprint $table) {
            $table->string('term_lake_uid')->after('artwork_citi_id')->nullable()->index();
        });

        DB::table('artwork_term')->update([
            'term_lake_uid' => DB::raw('\'TM-\' || term_citi_id')
        ]);

        Schema::table('artwork_term', function (Blueprint $table) {
            $table->dropColumn('term_citi_id');
        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {

        // terms
        Schema::table('terms', function (Blueprint $table) {
            $table->dropPrimary();
            $table->integer('citi_id')->first();
        });

        DB::table('terms')->update([
            'citi_id' => DB::raw('substr(lake_uid FROM 4)')
        ]);

        Schema::table('terms', function (Blueprint $table) {
            $table->primary('citi_id');
        });

        // categories
        Schema::table('categories', function (Blueprint $table) {
            $table->dropPrimary();
            $table->integer('citi_id')->first();
        });

        DB::table('categories')->update([
            'citi_id' => DB::raw('substr(lake_uid FROM 4)')
        ]);

        DB::table('categories')->update([
            'parent_id' => DB::raw('substr(parent_id FROM 4)')
        ]);

        Schema::table('categories', function (Blueprint $table) {
            $table->primary('citi_id');
            $table->integer('parent_id')->index()->change();
        });

        // artwork_category
        Schema::table('artwork_category', function (Blueprint $table) {
            $table->integer('category_citi_id');
        });

        DB::table('artwork_category')->update([
            'category_citi_id' => DB::raw('substr(category_lake_uid FROM 4)')
        ]);

        Schema::table('artwork_category', function (Blueprint $table) {
            $table->dropColumn('category_lake_uid');
        });

{'fraction_non_alphanumeric': 0.1759476478577602, 'fraction_numerical': 0.000864304235090752, 'mean_word_length': 2.321033210332103, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 103, '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': '424249', 'n_tokens_mistral': 2341, 'n_tokens_neox': 2269, 'n_words': 310}