var mysql = require('mysql');
|
var moment = require('moment');
|
var config = require('./config');
|
|
var mysqlClient = mysql.createConnection(config.mysql_2);
|
mysqlClient.connect(function(error) { if (error) return; });
|
|
var partition_name1 = "p" + moment().add(1, 'd').format("YYYYMMDD");
|
var partition_date1 = moment().add(2, 'd').format("YYYYMMDD");
|
|
var sql = "ALTER TABLE history ADD PARTITION (PARTITION " + partition_name1 + " VALUES LESS THAN ('" + partition_date1 + "'))";
|
// console.log(sql);
|
|
mysqlClient.query(sql, function (error, results, fields) { if (error) throw error; });
|
|
var partition_name2 = "p" + moment().add(-7, 'd').format("YYYYMMDD");
|
|
sql = "ALTER TABLE history DROP PARTITION " + partition_name2;
|
// console.log(sql);
|
|
mysqlClient.query(sql, function (error, results, fields) { if (error) throw error; });
|
|
mysqlClient.end();
|