<commit_before><?php

class CM_Db_SetupScript extends CM_Provision_Script_Abstract implements CM_Provision_Script_UnloadableInterface {

    use CM_Provision_Script_IsLoadedTrait;

    public function load(CM_OutputStream_Interface $output) {
        $mysqlDbClient = $this->getServiceManager()->getDatabases()->getMaster();

        $databaseName = $mysqlDbClient->getDatabaseName();
        $mysqlClient = $mysqlDbClient->getClientWithoutDatabase();
        $mysqlClient->createStatement('CREATE DATABASE ' . $mysqlClient->quoteIdentifier($databaseName))->execute();

        foreach (CM_Util::getResourceFiles('db/structure.sql') as $dump) {
            CM_Db_Db::runDump($databaseName, $dump);
        }
        $this->_setInitialVersion();
    }

    public function unload(CM_OutputStream_Interface $output) {
        $mysqlDbClient = $this->getServiceManager()->getDatabases()->getMaster();
        $mysqlClient = $mysqlDbClient->getClientWithoutDatabase();
        $databaseName = $mysqlDbClient->getDatabaseName();
        $mysqlClient->createStatement('DROP DATABASE ' . $mysqlDbClient->quoteIdentifier($databaseName))->execute();
    }

    public function reload(CM_OutputStream_Interface $output) {
        $tableNames = CM_Db_Db::exec('SHOW TABLES')->fetchAllColumn();
        CM_Db_Db::exec('SET foreign_key_checks = 0;');
        foreach ($tableNames as $table) {
            CM_Db_Db::delete($table);
        }
        CM_Db_Db::exec('SET foreign_key_checks = 1;');<commit_msg>Set initial app version also when *reloading* db<commit_after><?php

class CM_Db_SetupScript extends CM_Provision_Script_Abstract implements CM_Provision_Script_UnloadableInterface {

    use CM_Provision_Script_IsLoadedTrait;

    public function load(CM_OutputStream_Interface $output) {
        $mysqlDbClient = $this->getServiceManager()->getDatabases()->getMaster();

        $databaseName = $mysqlDbClient->getDatabaseName();
        $mysqlClient = $mysqlDbClient->getClientWithoutDatabase();
        $mysqlClient->createStatement('CREATE DATABASE ' . $mysqlClient->quoteIdentifier($databaseName))->execute();

        foreach (CM_Util::getResourceFiles('db/structure.sql') as $dump) {
            CM_Db_Db::runDump($databaseName, $dump);
        }
        $this->_setInitialVersion();
    }

    public function unload(CM_OutputStream_Interface $output) {
        $mysqlDbClient = $this->getServiceManager()->getDatabases()->getMaster();
        $mysqlClient = $mysqlDbClient->getClientWithoutDatabase();
        $databaseName = $mysqlDbClient->getDatabaseName();
        $mysqlClient->createStatement('DROP DATABASE ' . $mysqlDbClient->quoteIdentifier($databaseName))->execute();
    }

    public function reload(CM_OutputStream_Interface $output) {
        $tableNames = CM_Db_Db::exec('SHOW TABLES')->fetchAllColumn();
        CM_Db_Db::exec('SET foreign_key_checks = 0;');
        foreach ($tableNames as $table) {
            CM_Db_Db::delete($table);
        }
        CM_Db_Db::exec('SET foreign_key_checks = 1;');
        $this->_setInitialVersion();
{'fraction_non_alphanumeric': 0.1287581699346405, 'fraction_numerical': 0.00130718954248366, 'mean_word_length': 4.170608108108108, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, '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': '97705', 'n_tokens_mistral': 868, 'n_tokens_neox': 843, 'n_words': 127}