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



$migrations->Run('01_add_cdn_mirror_ic_field_directory.php', <<<'DB_UPDATE_FILE'
<?php
/** @var \Claromentis\Setup\SetupFacade $migrations */
$new_dir = $migrations->GetDataDir().'/cdn_mirror/infocapture/field/';

// Create $new_dir path with 0777 permissions
if (!is_dir($new_dir))
	mkdir($new_dir, 0777, true);

DB_UPDATE_FILE
);


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

$db->DropTable('fuu_outlook_attaches');
$db->DropTable('fuu_outlook_emails');

DB_UPDATE_FILE
);


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

$db->query("UPDATE simple_acl SET object_code=str:new WHERE object_code=str:old", 'news', 'comms');

DB_UPDATE_FILE
);


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

@$db->DropIndex('oauth_access_tokens', 'oauth_access_tokens_session_id_foreign');

DB_UPDATE_FILE
);


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