<commit_before><?

include "lib.php";

$stmt = new tidy_sql($db, "SELECT `value` FROM Config WHERE `key`='version'");
$val = $stmt->query();
$version = $val[0]["value"];

echo "Current version: <strong>{$version}</strong><br/>";

function update() {
	global $version;
	$stmt = new tidy_sql($db, "REPLACE INTO Config SET `value`=? WHERE `key`='version'", "s");
	$stmt->query($version);
	echo "Updated to version <strong>{$version}</strong><br/>";
}

if ($version == null) {
	$stmt = new tidy_sql($db, "
		CREATE TABLE `Config` (
		  `key` varchar(10) NOT NULL,
		  `value` text NOT NULL
		) ENGINE=MyISAM DEFAULT CHARSET=latin1
	");
	$stmt->query();
	$version = 1;
	update();
}

if ($version == 1) {
	$stmt = new tidy_sql($db, "
		ALTER TABLE `Questions`
		ADD `QuestionaireID` int NULL,
		ADD `ModuleID` varchar(10) COLLATE 'utf8_general_ci' NULL AFTER `QuestionaireID`,
		COMMENT='';"
	);
	$stmt->query();
	$version = 2;
	update();
}
echo "<strong>Finished</strong>";<commit_msg>More database changes<commit_after><?

include "lib.php";

$stmt = new tidy_sql($db, "SELECT `value` FROM Config WHERE `key`='version'");
$val = $stmt->query();
$version = $val[0]["value"];

echo "Current version: <strong>{$version}</strong><br/>";

function update() {
	global $version;
	$stmt = new tidy_sql($db, "REPLACE INTO Config SET `value`=? WHERE `key`='version'", "s");
	$stmt->query($version);
	echo "Updated to version <strong>{$version}</strong><br/>";
}

if ($version == null) {
	$stmt = new tidy_sql($db, "
		CREATE TABLE `Config` (
		  `key` varchar(10) NOT NULL,
		  `value` text NOT NULL
		) ENGINE=MyISAM DEFAULT CHARSET=latin1
	");
	$stmt->query();
	
	$version = 1;
	update();
}

if ($version == 1) {
	$stmt = new tidy_sql($db, "
		ALTER TABLE `Questions`
		ADD `QuestionaireID` int NULL,
		ADD `ModuleID` varchar(10) COLLATE 'utf8_general_ci' NULL AFTER `QuestionaireID`,
		COMMENT='';"
	);
	$stmt->query();
	
	$version = 2;
	update();
}

if ($version == 2) {
	$stmt = new tidy_sql($db, "ALTER TABLE `Config`
	COMMENT='' COLLATE 'utf8_general_ci';");
	$stmt->query();
	
	$version = 3;
	update();
}

if ($version == 3) {
	$stmt = new tidy_sql($db, "ALTER TABLE `Modules`
	ADD `Fake` bit NOT NULL,
	COMMENT='';")
	$stmt->query();
	
	$version = 4;
	update();
}
echo "<strong>Finished</strong>";
{'fraction_non_alphanumeric': 0.20680628272251309, 'fraction_numerical': 0.010907504363001745, 'mean_word_length': 4.7468671679198, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 29, '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': '7269951', 'n_tokens_mistral': 912, 'n_tokens_neox': 850, 'n_words': 222}