diff --git a/adm/dbupgrade.php b/adm/dbupgrade.php index 8c06a3644..f9dadf600 100644 --- a/adm/dbupgrade.php +++ b/adm/dbupgrade.php @@ -13,6 +13,7 @@ if ($is_admin != 'super') { $is_execute = isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST'; $migration_result = array('success' => true, 'applied' => 0, 'skipped' => 0, 'errors' => array()); $shop_install_result = null; +$action = ''; if ($is_execute) { check_demo(); @@ -20,6 +21,8 @@ if ($is_execute) { $action = isset($_POST['action']) ? trim($_POST['action']) : 'migrate'; if ($action === 'install_shop') { $shop_install_result = g5_shop_install_run(); + } elseif ($action === 'record_existing') { + $migration_result = g5_migration_run('', true); } else { $migration_id = isset($_POST['migration_id']) ? trim($_POST['migration_id']) : ''; $migration_result = g5_migration_run($migration_id); @@ -29,8 +32,11 @@ if ($is_execute) { $migration_statuses = g5_migration_status(); $pending_count = 0; +$unrecorded_count = 0; foreach ($migration_statuses as $migration_status) { - if (isset($migration_status['error']) || $migration_status['status'] !== 'success' || $migration_status['checksum_changed']) { + if (isset($migration_status['status']) && $migration_status['status'] === 'unrecorded') { + $unrecorded_count++; + } elseif (isset($migration_status['error']) || $migration_status['status'] !== 'success' || $migration_status['checksum_changed']) { $pending_count++; } } @@ -40,9 +46,11 @@ if ($shop_install_result !== null && $shop_install_result['success']) { } elseif ($shop_install_result !== null) { $db_upgrade_msg = '쇼핑몰 설치에 실패했습니다. 오류 내용을 확인해 주십시오.'; } elseif (!$is_execute) { - $db_upgrade_msg = $pending_count ? '적용하지 않은 DB 마이그레이션이 있습니다. 아래 내용을 확인한 뒤 실행해 주십시오.' : 'DB 마이그레이션이 모두 적용되어 있습니다.'; + $db_upgrade_msg = $pending_count ? '확인·실행이 필요한 DB 마이그레이션이 있습니다. 아래 내용을 확인해 주십시오.' : ($unrecorded_count ? '현재 실행할 변경은 없지만 기존 상태 확인 이력이 등록되지 않았습니다.' : 'DB 마이그레이션이 모두 적용되어 있습니다.'); } elseif (!$migration_result['success']) { $db_upgrade_msg = 'DB 마이그레이션에 실패했습니다. 오류 내용을 확인해 주십시오.'; +} elseif ($action === 'record_existing') { + $db_upgrade_msg = '기존 상태 확인 이력 ' . (int) $migration_result['skipped'] . '건을 등록했습니다. 선행 항목에 실행이 필요하거나 실패 이력이 있으면 등록을 중단합니다.'; } elseif ($migration_result['applied'] || $migration_result['skipped']) { $db_upgrade_msg = 'DB 마이그레이션이 완료되었습니다.'; } else { @@ -56,6 +64,10 @@ $dbupgrade_token = get_admin_token();

+ +

실행 불필요 건: 현재 실행 조건상 건너뛰는 항목입니다. 과거 실행 성공을 의미하지 않으며, 선행 작업 후에는 결과가 달라질 수 있습니다. 기존 상태 등록은 처음부터 연속해서 실행 불필요한 항목만 기록합니다.

+ +

대기 항목에는 데이터 보정 등 조회만으로 완료를 판단할 수 없는 작업도 포함됩니다. 조회 시 DB 변경이나 이력 등록은 수행하지 않습니다.

@@ -71,6 +83,13 @@ $dbupgrade_token = get_admin_token();
+ +
+ + + +
+
@@ -105,8 +124,8 @@ $dbupgrade_token = get_admin_token(); @@ -131,6 +150,7 @@ $dbupgrade_token = get_admin_token();