fix(db): V16 补充 conversation 租户时间索引,脚本使用 MYSQL_PWD 避免密码暴露,增加生产部署提示

This commit is contained in:
2026-07-07 18:50:26 +08:00
parent 3b45a669f9
commit 4dbc190f68
3 changed files with 21 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ MYSQL_USER="${MYSQL_USER:-root}"
MYSQL_PASSWORD="${MYSQL_PASSWORD:-root}"
MYSQL_DB="${MYSQL_DB:-sino_mci}"
MONTHS_AHEAD="${MONTHS_AHEAD:-3}"
DRY_RUN="${DRY_RUN:-0}"
TABLES=(
mci_message_event
@@ -24,12 +25,21 @@ TABLES=(
mci_conversation
)
if ! command -v mysql >/dev/null 2>&1; then
echo "Error: mysql client not found in PATH" >&2
exit 1
fi
echo "Extending monthly partitions for database: ${MYSQL_DB}"
echo "Host: ${MYSQL_HOST}:${MYSQL_PORT}, User: ${MYSQL_USER}, Months ahead: ${MONTHS_AHEAD}"
for table in "${TABLES[@]}"; do
echo " -> ${table}"
mysql -h "${MYSQL_HOST}" -P "${MYSQL_PORT}" -u "${MYSQL_USER}" -p"${MYSQL_PASSWORD}" "${MYSQL_DB}" \
if [ "${DRY_RUN}" = "1" ]; then
echo " CALL ExtendMonthlyPartitions('${table}', ${MONTHS_AHEAD});"
continue
fi
MYSQL_PWD="${MYSQL_PASSWORD}" mysql -h "${MYSQL_HOST}" -P "${MYSQL_PORT}" -u "${MYSQL_USER}" "${MYSQL_DB}" \
-e "CALL ExtendMonthlyPartitions('${table}', ${MONTHS_AHEAD});"
done