<commit_before><?php
    function migrate( $sql_array = [] ) {
        include_once '../../config/config-local.php';
        include_once '../../models/database.php';
        include_once '../../models/db.php';

        global $config;

        $config = getConfig()[ getEnv( 'ENVIRONMENT' ) ];
        dbInit();

        foreach ( $sql_array as $sql ) {
            try {
                $res = db( $sql );
            }
            catch ( DBException $e ) {
                die( "Migration failed. SQL query died with the following error: " . mysql_error() . "\n" );
            }
        }
        echo "Migration successful.\n";
    }
?>
<commit_msg>Add migrate class<commit_after><?php
    abstract class Migration {
        protected static function migrate( $sql ) {
            include_once '../../config/config-local.php';
            include_once '../../models/database.php';
            include_once '../../models/db.php';

            global $config;

            $config = getConfig()[ getEnv( 'ENVIRONMENT' ) ];
            dbInit();

            try {
                $res = db( $sql );
            }
            catch ( DBException $e ) {
                die( "Migration failed. SQL query died with the following error: " . mysql_error() . "\n" );
            }
            echo "Migration successful.\n";
        } 
    
        public static function addField( $table, $field, $description ) {
            $sql = "ALTER TABLE
                        $table
                    ADD COLUMN
                        field` $description;";
            self::migrate( $sql );              
        }
    
        public static function renameField( $table, $oldName, $newName, $description ) {
            $sql = "ALTER TABLE
                        $table
                    CHANGE'
                        `$oldName` `$newName` $description;";
            self::migrate( $sql );
        }
    
        public static function DropField ($table, $field ) {
            $sql = "ALTER TABLE
                        $table
                    DROP COLUMN
                        $field;";
            self::migrate( $sql );
        }
	
	    public static function createTable( $tableName, $fields = [] ) {
		    $attributes = [];
		    foreach ( $fields as $field => description ) {
			    $attributes[] = "'$field' $description";
		    }
		    $attributes = implode( ',', $attributes );
		    $sql = "CREATE TABLE IF NOT EXISTS
			        $tableName (
				        $attributes
			        );
			        ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
		    self::migrate( $sql );
	    }
    }
?>

{'fraction_non_alphanumeric': 0.12686567164179105, 'fraction_numerical': 0.0007462686567164179, 'mean_word_length': 1.2662721893491125, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '5976886', 'n_tokens_mistral': 751, 'n_tokens_neox': 686, 'n_words': 171}