From 4e24302f99ed426e24194b423513b7e9e8ba3c58 Mon Sep 17 00:00:00 2001
From: yuebao liang <cn_lyb@163.com>
Date: Sat, 06 Jul 2019 11:25:50 +0800
Subject: [PATCH] 添加了4个分区

---
 server3.js |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/server3.js b/server3.js
index 966187b..3344fca 100644
--- a/server3.js
+++ b/server3.js
@@ -6,11 +6,18 @@
 mysqlClient.connect(function(error) { if (error) return; });
 
 var partition_name = "p" + moment().add(1, 'M').format("YYYYMM");
-var partition_date = moment().add(2, 'M').format("YYYYMM");
+var partition_date = moment().add(2, 'M').format("YYYYMM01");
 
 var sql = "ALTER TABLE history_minutely ADD PARTITION (PARTITION " + partition_name + " VALUES LESS THAN ('" + partition_date + "'))";
-// console.log(sql);
+mysqlClient.query(sql, function (error, results, fields) { if (error) {console.log("history_minutely:", error);} });
 
-mysqlClient.query(sql, function (error, results, fields) { if (error) throw error; });
+sql = "ALTER TABLE history_10min ADD PARTITION (PARTITION " + partition_name + " VALUES LESS THAN (TO_DAYS('" + partition_date + "')))";
+mysqlClient.query(sql, function (error, results, fields) { if (error) {console.log("history_10min:", error);} });
+
+sql = "ALTER TABLE history_hourly ADD PARTITION (PARTITION " + partition_name + " VALUES LESS THAN (TO_DAYS('" + partition_date + "')))";
+mysqlClient.query(sql, function (error, results, fields) { if (error) {console.log("history_hourly:", error);} });
+
+sql = "ALTER TABLE history_daily ADD PARTITION (PARTITION " + partition_name + " VALUES LESS THAN (TO_DAYS('" + partition_date + "')))";
+mysqlClient.query(sql, function (error, results, fields) { if (error) {console.log("history_daily:", error);} });
 
 mysqlClient.end();
\ No newline at end of file

--
Gitblit v1.8.0