<commit_before><?php

namespace App\Library\Migrations;

use Aic\Hub\Foundation\Concerns\HasAbstractProperties;

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

class RenameColumnMigration extends Migration
{
    use HasAbstractProperties;

    protected $columns;

    protected $prefix;

    public function __construct()
    {
        $this->checkProperty('columns');

        $this->prefix = Schema::getConnection()->getTablePrefix();
    }

    public function up()
    {
        foreach ($this->columns as $tableName => $columns) {
            Schema::table($tableName, function (Blueprint $table) use ($columns) {
                foreach ($columns as $oldColumn => $newColumn) {
                    $table->renameColumn($oldColumn, $newColumn);
                }
            });
        }

        foreach ($this->indexes as $tableName => $indexes) {
            Schema::table($tableName, function (Blueprint $table) use ($indexes) {
                foreach ($indexes as $oldIndex => $newIndex) {
                    $table->renameIndex($this->prefix . $oldIndex, $this->prefix . $newIndex);
                }
            });
        }
    }

    public function down()
    {
        foreach ($this->columns as $tableName => $columns) {
            Schema::table($tableName, function (Blueprint $table) use ($columns) {
                foreach ($columns as $oldColumn => $newColumn) {
                    $table->renameColumn($newColumn, $oldColumn);
                }
            });
        }

        foreach ($this->indexes as $tableName => $indexes) {
            Schema::table($tableName, function (Blueprint $table) use ($indexes) {
                foreach ($indexes as $oldIndex => $newIndex) {
                    $table->renameIndex($this->prefix . $newIndex, $this->prefix . $oldIndex);
                }
            });
        }
    }
}<commit_msg>Fix column rename calls for SQLite [API-302]<commit_after><?php

namespace App\Library\Migrations;

use Aic\Hub\Foundation\Concerns\HasAbstractProperties;

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

class RenameColumnMigration extends Migration
{
    use HasAbstractProperties;

    protected $columns;

    protected $prefix;

    public function __construct()
    {
        $this->checkProperty('columns');

        $this->prefix = Schema::getConnection()->getTablePrefix();
    }

    public function up()
    {
        foreach ($this->columns as $tableName => $columns) {
            foreach ($columns as $old => $new) {
                Schema::table($tableName, function (Blueprint $table) use ($old, $new) {
                    $table->renameColumn($old, $new);
                });
            }
        }

        foreach ($this->indexes as $tableName => $indexes) {
            Schema::table($tableName, function (Blueprint $table) use ($indexes) {
                foreach ($indexes as $oldIndex => $newIndex) {
                    $table->renameIndex($this->prefix . $oldIndex, $this->prefix . $newIndex);
                }
            });
        }
    }

    public function down()
    {
        foreach ($this->columns as $tableName => $columns) {
            foreach ($columns as $old => $new) {
                Schema::table($tableName, function (Blueprint $table) use ($old, $new) {
                    $table->renameColumn($new, $old);
                });
            }
        }

        foreach ($this->indexes as $tableName => $indexes) {
            Schema::table($tableName, function (Blueprint $table) use ($indexes) {
                foreach ($indexes as $oldIndex => $newIndex) {
                    $table->renameIndex($this->prefix . $newIndex, $this->prefix . $oldIndex);
                }
            });
        }
    }
}
{'fraction_non_alphanumeric': 0.13417460726242597, 'fraction_numerical': 0.0007725985063095545, 'mean_word_length': 2.0534591194968552, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '6639472', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1033, 'n_words': 226}