feat(db): V15 为高频表添加 RANGE 月分区
This commit is contained in:
36
scripts/extend-mysql-partitions.sh
Executable file
36
scripts/extend-mysql-partitions.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# 扩展 MySQL RANGE 月分区
|
||||
# 为 mci_message_event / mci_send_record / mci_conversation 自动添加未来月份分区。
|
||||
# 依赖 V15__add_range_partitions.sql 中创建的存储过程 ExtendMonthlyPartitions。
|
||||
#
|
||||
# 用法示例:
|
||||
# ./scripts/extend-mysql-partitions.sh
|
||||
# MYSQL_HOST=127.0.0.1 MYSQL_PORT=3306 MYSQL_USER=root MYSQL_PASSWORD=root MYSQL_DB=sino_mci ./scripts/extend-mysql-partitions.sh
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
MYSQL_HOST="${MYSQL_HOST:-mci-mysql}"
|
||||
MYSQL_PORT="${MYSQL_PORT:-3306}"
|
||||
MYSQL_USER="${MYSQL_USER:-root}"
|
||||
MYSQL_PASSWORD="${MYSQL_PASSWORD:-root}"
|
||||
MYSQL_DB="${MYSQL_DB:-sino_mci}"
|
||||
MONTHS_AHEAD="${MONTHS_AHEAD:-3}"
|
||||
|
||||
TABLES=(
|
||||
mci_message_event
|
||||
mci_send_record
|
||||
mci_conversation
|
||||
)
|
||||
|
||||
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}" \
|
||||
-e "CALL ExtendMonthlyPartitions('${table}', ${MONTHS_AHEAD});"
|
||||
done
|
||||
|
||||
echo "Done."
|
||||
Reference in New Issue
Block a user