fix: #42 SMS5 DB에 G5_TABLE_PREFIX 적용

- 기존 sms5_* 테이블 존재 시 dbupgrade에서 테이블명 변경
This commit is contained in:
chym1217
2025-08-19 15:31:58 +09:00
parent 5da91ab73e
commit cb1fadba4c
3 changed files with 31 additions and 1 deletions

View File

@ -269,6 +269,26 @@ while ($row = sql_fetch_array($result)){
} }
} }
// SMS5 테이블 G5_TABLE_PREFIX 적용
if($g5['sms5_prefix'] != 'sms5_' && sql_num_rows(sql_query("show tables like 'sms5_config'")))
{
$tables = array('config','write','history','book','book_group','form','form_group');
foreach($tables as $name){
$old_table = 'sms5_' . $name;
$new_table = $g5['sms5_prefix'] . $name;
// 기존 테이블이 있고, G5_TABLE_PREFIX 적용 테이블이 없을 경우 → 테이블명 변경
if(sql_num_rows(sql_query("SHOW TABLES LIKE '{$old_table}' "))){
if(!sql_num_rows(sql_query("SHOW TABLES LIKE '{$new_table}' "))){
sql_query("RENAME TABLE {$old_table} TO {$new_table}", false);
}
}
}
$is_check = true;
}
$is_check = run_replace('admin_dbupgrade', $is_check); $is_check = run_replace('admin_dbupgrade', $is_check);
$db_upgrade_msg = $is_check ? 'DB 업그레이드가 완료되었습니다.' : '더 이상 업그레이드 할 내용이 없습니다.<br>현재 DB 업그레이드가 완료된 상태입니다.'; $db_upgrade_msg = $is_check ? 'DB 업그레이드가 완료되었습니다.' : '더 이상 업그레이드 할 내용이 없습니다.<br>현재 DB 업그레이드가 완료된 상태입니다.';

View File

@ -5,6 +5,16 @@ include_once(G5_ADMIN_PATH.'/admin.lib.php');
include_once(G5_SMS5_PATH.'/sms5.lib.php'); include_once(G5_SMS5_PATH.'/sms5.lib.php');
if (!strstr($_SERVER['SCRIPT_NAME'], 'install.php')) { if (!strstr($_SERVER['SCRIPT_NAME'], 'install.php')) {
// SMS5 테이블 G5_TABLE_PREFIX 적용
if($g5['sms5_prefix'] != 'sms5_' && sql_num_rows(sql_query("show tables like 'sms5_config'")))
{
echo '<script>
alert("기존 SMS5 테이블을 sms5 prefix 기준으로 변경합니다.\n(DB 업그레이드에서 자동 적용됩니다.)");
location.href = "'.G5_ADMIN_URL.'/dbupgrade.php";
</script>';
exit;
}
if(!sql_num_rows(sql_query(" show tables like '{$g5['sms5_config_table']}' "))) if(!sql_num_rows(sql_query(" show tables like '{$g5['sms5_config_table']}' ")))
goto_url('install.php'); goto_url('install.php');

View File

@ -20,7 +20,7 @@ define('G5_ICODE_LMS_MAX_LENGTH', 1500); // 구버전 LMS 최대길이
define('G5_ICODE_JSON_MAX_LENGTH', 2000); // JSON 버전 LMS 최대길이 define('G5_ICODE_JSON_MAX_LENGTH', 2000); // JSON 버전 LMS 최대길이
// SMS 테이블명 // SMS 테이블명
$g5['sms5_prefix'] = 'sms5_'; $g5['sms5_prefix'] = G5_TABLE_PREFIX.'sms5_';
$g5['sms5_config_table'] = $g5['sms5_prefix'] . 'config'; $g5['sms5_config_table'] = $g5['sms5_prefix'] . 'config';
$g5['sms5_write_table'] = $g5['sms5_prefix'] . 'write'; $g5['sms5_write_table'] = $g5['sms5_prefix'] . 'write';
$g5['sms5_history_table'] = $g5['sms5_prefix'] . 'history'; $g5['sms5_history_table'] = $g5['sms5_prefix'] . 'history';