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



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

$db->AddColumn("blog_post", "notification_sent", "BOOL DEFAULT 0");
$db->query("UPDATE blog_post SET notification_sent=1");

DB_UPDATE_FILE
);


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

$db->AddColumn("fb_field", "is_calculated", "BOOL DEFAULT 0");

$db->query("UPDATE fb_field SET is_calculated=1 WHERE default_value LIKE '{#%'");

DB_UPDATE_FILE
);


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

$db->query("UPDATE tags SET aggregation=154 WHERE aggregation=117");

DB_UPDATE_FILE
);


$migrations->Run('02_comment_indexes.php', <<<'DB_UPDATE_FILE'
<?php
/** @var \Claromentis\Setup\SetupFacade $migrations */

$db = $migrations->GetDb();
$db->CreateIndex('discussions', 'idx_parent_id', 'parent_id');
$db->CreateIndex('discussions', 'idx_aggregation_object_id_parent_id', 'aggregation', 'object_id', 'parent_id');

DB_UPDATE_FILE
);


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