<?php
$_db_migration_to = '04.02';
if (!isset($migrations) || !is_object($migrations))
	die("This file cannot be executed directly");
$migrations->CheckValid($_db_migration_to);
//===========================================================================================



$migrations->Run('01_quiz_training_column.php', <<<'DB_UPDATE_FILE'
<?php
/**
 * @var \Claromentis\Setup\SetupFacade $migrations
 */
$database = $migrations->GetDb();

$database->AddColumn('quiz', 'training_record', 'BOOL NOT_NULL DEFAULT 0');

DB_UPDATE_FILE
);


$migrations->Run('02_update_training_quizzes.php', <<<'DB_UPDATE_FILE'
<?php
/**
 * @var \Claromentis\Setup\SetupFacade $migrations
 */
$database = $migrations->GetDb();

// Update Quizzes with qualification code IDs to opt-in for training records
$database->query('UPDATE quiz SET training_record = 1 WHERE qualification_code_id != 0');

DB_UPDATE_FILE
);


//===========================================================================================
$migrations->SetVersion('04.02');
