public function __construct($configName = '')
 {
     $configName = empty($configName) ? Module::getDbOption('config_name', '') : $configName;
     $this->versionConfig = new VersionConfig($configName);
     $this->versionTable = new VersionTable($this->getConfigVal('migration_table'));
     Module::setDbOption('config_name', $this->versionConfig->getConfigName());
 }
Ejemplo n.º 2
0
 function DoUninstall()
 {
     //launch upgrade when reinstalled module
     \Sprint\Migration\Module::setDbOption('upgrade_version', 'unknown');
     DeleteDirFiles(__DIR__ . "/admin", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/admin");
     UnRegisterModule($this->MODULE_ID);
 }
$listView = $_POST["step_code"] == "migration_new" || $_POST["step_code"] == "migration_list";
if ($_SERVER["REQUEST_METHOD"] == "POST" && $listView && check_bitrix_sessid('send_sessid')) {
    /** @noinspection PhpIncludeInspection */
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_js.php";
    $search = !empty($_POST['search']) ? trim($_POST['search']) : '';
    $search = Sprint\Migration\Locale::convertToUtf8IfNeed($search);
    $taskUrl = $versionManager->getConfigVal('tracker_task_url');
    $webdir = $versionManager->getConfigVal('migration_webdir');
    if ($_POST["step_code"] == "migration_new") {
        \Sprint\Migration\Module::setDbOption('admin_versions_view', 'new');
        \Sprint\Migration\Module::setDbOption('admin_versions_search', $search);
        $versions = $versionManager->getVersions(array('status' => 'new', 'search' => $search));
    } else {
        \Sprint\Migration\Module::setDbOption('admin_versions_view', 'list');
        \Sprint\Migration\Module::setDbOption('admin_versions_search', $search);
        $versions = $versionManager->getVersions(array('status' => '', 'search' => $search));
    }
    ?>
    <?php 
    if (!empty($versions)) {
        ?>
        <table class="c-migration-list">
        <?php 
        foreach ($versions as $aItem) {
            ?>
            <tr>
                <td class="c-migration-list-l">
                <?php 
            if ($aItem['status'] == 'new') {
                ?>
Ejemplo n.º 4
0
<?php

if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["step_code"] == "migration_new" && check_bitrix_sessid('send_sessid')) {
    /** @noinspection PhpIncludeInspection */
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_js.php";
    \Sprint\Migration\Module::setDbOption('admin_versions_view', 'new');
    $versions = $versionManager->getVersions('up');
    ?>
    <?php 
    if (!empty($versions)) {
        ?>

        <?php 
        foreach ($versions as $aItem) {
            ?>
            <div class="c-migration-block">
                <a href="#" onclick="migrationMigrationInfo('<?php 
            echo $aItem['version'];
            ?>
');return false;" class="c-migration-item-is_new"><?php 
            echo $aItem['version'];
            ?>
</a>
                &nbsp;
                <input onclick="migrationExecuteStep('migration_execute', {version: '<?php 
            echo $aItem['version'];
            ?>
', action: 'up'});" value="<?php 
            echo GetMessage('SPRINT_MIGRATION_UP');
            ?>
" type="button">
Ejemplo n.º 5
0
            }
        });
    }

    function migrationMigrationInfo(version) {
        migrationExecuteStep('migration_info', {version: version}, function (data) {
            $('#migration_info_' + version).empty().html(data);
        });
    }

</script>

<script language="JavaScript">
    <?php 
$views = array('list', 'new', 'status');
$curView = \Sprint\Migration\Module::getDbOption('admin_versions_view');
$curView = in_array($curView, $views) ? $curView : 'list';
?>
    
    var migrationView = '<?php 
echo $curView;
?>
';

    $(document).ready(function () {
        migrationMigrationToggleView(migrationView);
    });
    
</script>

<?php 
Ejemplo n.º 6
0
<?php

if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["step_code"] == "migration_info" && check_bitrix_sessid('send_sessid')) {
    /** @noinspection PhpIncludeInspection */
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_js.php";
    $version = isset($_POST['version']) ? $_POST['version'] : 0;
    $descr = $versionManager->getVersionDescription($version);
    $webdir = \Sprint\Migration\Module::getMigrationWebDir();
    ?>
    <div class="c-migration-descr">
        <?php 
    echo empty($descr['description']) ? GetMessage('SPRINT_MIGRATION_EMPTY_DESCR') : $descr['description'];
    ?>

        <?php 
    if ($webdir && $descr['location']) {
        ?>
            <br/>
            <?php 
        $href = '/bitrix/admin/fileman_file_view.php?' . http_build_query(array('lang' => LANGUAGE_ID, 'site' => SITE_ID, 'path' => $webdir . '/' . $version . '.php'));
        ?>
            <a href="<?php 
        echo $href;
        ?>
" target="_blank" title=""><?php 
        echo GetMessage('SPRINT_MIGRATION_VIEW');
        ?>
</a>
        <?php 
    }
    ?>
Ejemplo n.º 7
0
<?php

require_once __DIR__ . '/../classes/Sprint/Migration/Module.php';
\Sprint\Migration\Module::loadLocale(array("SPRINT_MIGRATION_SETTINGS" => "Настройка", "SPRINT_MIGRATION_MIGRATION_DIR" => "Директория для миграций", "SPRINT_MIGRATION_SAVE" => "Сохранить", "SPRINT_MIGRATION_MODULE_NAME" => "Миграции для разработчиков", "SPRINT_MIGRATION_MODULE_DESCRIPTION" => "Модуль для управления миграциями бд, создание, установка, откат миграций", "SPRINT_MIGRATION_PARTNER_NAME" => "Андрей Рябин", "SPRINT_MIGRATION_PARTNER_URI" => "http://dev.1c-bitrix.ru/community/webdev/user/39653/blog/", "SPRINT_MIGRATION_MENU_SPRINT" => "Спринт", "SPRINT_MIGRATION_MENU_MIGRATIONS" => "Миграции", "SPRINT_MIGRATIONS" => "Миграции", "SPRINT_MIGRATION_EMPTY_DESCR" => "нет описания", "SPRINT_MIGRATION_DESCR1" => "описание миграции", "SPRINT_MIGRATION_DESCR2" => "Описание миграции", "SPRINT_MIGRATION_TAB1_TITLE" => "Список миграций", "SPRINT_MIGRATION_TAB2_TITLE" => "Справка по модулю", "SPRINT_MIGRATION_LIST2" => "Список", "SPRINT_MIGRATION_TAB1" => "Миграции", "SPRINT_MIGRATION_TAB2" => "Помощь", "SPRINT_MIGRATION_LIST_EMPTY" => "пуст", "SPRINT_MIGRATION_UP" => "Установить", "SPRINT_MIGRATION_DOWN" => "Откатить", "SPRINT_MIGRATION_UP_START" => "Установить новые", "SPRINT_MIGRATION_DOWN_START" => "Откатить", "SPRINT_MIGRATION_UP_CONFIRM" => "Установить новые миграции?", "SPRINT_MIGRATION_DOWN_CONFIRM" => "Откатить все установленные миграции?", "SPRINT_MIGRATION_GENERATE" => "Создать", "SPRINT_MIGRATION_REFRESH" => "Обновить", "SPRINT_MIGRATION_TOGGLE_LIST" => "Все", "SPRINT_MIGRATION_TOGGLE_NEW" => "Новые", "SPRINT_MIGRATION_TOGGLE_STATUS" => "Суммарно", "SPRINT_MIGRATION_IS_NEW" => "Новые миграции", "SPRINT_MIGRATION_IS_INSTALLED" => "Установленные", "SPRINT_MIGRATION_IS_UNKNOWN" => "Неизвестные", "SPRINT_MIGRATION_VIEW" => "просмотр файла", "SPRINT_MIGRATION_UPGRADE_RELOAD" => "Пересоздание служебных таблиц модуля", "SPRINT_MIGRATION_UPGRADE_VERSION" => "Версия бд", "SPRINT_MIGRATION_TEXT2" => "Подробнее о модуле", "SPRINT_MIGRATION_LEGEND_NEW" => "Новые миграции (только файл)", "SPRINT_MIGRATION_LEGEND_INSTALLED" => "Установленные миграции (файл + запись об установке)", "SPRINT_MIGRATION_LEGEND_UNKNOWN" => "Неизвестные миграции (только запись об установке)"));
Ejemplo n.º 8
0
 protected function getVersionFile($versionName)
 {
     return Module::getMigrationDir() . '/' . $versionName . '.php';
 }
Ejemplo n.º 9
0
<?php

$module_id = "sprint.migration";
global $APPLICATION;
$MODULE_RIGHT = $APPLICATION->GetGroupRight($module_id);
if (!($MODULE_RIGHT >= "R")) {
    $APPLICATION->AuthForm("ACCESS_DENIED");
}
CModule::IncludeModule($module_id);
if ($_SERVER['REQUEST_METHOD'] == "POST" && check_bitrix_sessid()) {
    if (!empty($_REQUEST["remove_options"])) {
        \Sprint\Migration\Module::removeDbOptions();
    }
}
?>

<p>
    <a href="/bitrix/admin/sprint_migrations.php?lang=<?php 
echo LANGUAGE_ID;
?>
"><?php 
echo GetMessage('SPRINT_MIGRATION_GOTO_MIGRATION');
?>
</a>
</p>
<p>
    <a href="https://bitbucket.org/andrey_ryabin/sprint.migration" target="_blank"><?php 
echo GetMessage('SPRINT_MIGRATION_HELP_DOC');
?>
</a>
</p>
" onclick="migrationMigrationsDownConfirm();" />

    <div class="c-migration-filter">
        <?php 
$search = \Sprint\Migration\Module::getDbOption('admin_versions_search', '');
?>
        <input placeholder="<?php 
echo GetMessage('SPRINT_MIGRATION_SEARCH');
?>
" style="" type="text" value="<?php 
echo $search;
?>
" class="adm-input" name="migration_search"/>

        <?php 
$view = \Sprint\Migration\Module::getDbOption('admin_versions_view', 'list');
?>
        <select class="c-migration-stat">
            <option <?php 
if ($view == 'list') {
    ?>
selected="selected"<?php 
}
?>
 value="list"><?php 
echo GetMessage('SPRINT_MIGRATION_TOGGLE_LIST');
?>
</option>
            <option <?php 
if ($view == 'new') {
    ?>