Commit 103d7c34 authored by 智勇's avatar 智勇

drop sql

parent 46d0c0bc
const Router = require('koa-router')
const bodyParser = require('koa-bodyparser')
const _ = require('lodash')
const mysql = require('mysql2/promise');
const jenkinsService = require('../service/jenkinsService')
const k8sService = require('../service/k8sService')
const { DBConfig } = require('../service/mongoService')
......@@ -128,10 +128,31 @@ const dbSyncQuery = async function (ctx) {
ctx.body = ctx.ok({ status: 'queue', log: { body: '' } })
}
const getDropSQL = async (ctx) => {
const { dbName } = ctx.request.query
const select = `select \`sql\`,base from core_sqlrecord where to_days(date) = to_days(now())
and state='Execute Successfully' and \`sql\` like '%drop %'`
const connection = await mysql.createConnection({
host: '172.30.4.8',
user: 'sync_del',
password: 'JhHgXdbopEPO6r6K',
database: 'yearning',
})
const [rows] = await connection.execute(select)
const res = rows.reduce((a, b) => {
if (b.base === dbName) {
a += `${b.sql};`
}
return a
}, '')
ctx.body = res
}
const router = new Router()
router
.get('/get_dbs', getDBs)
.get('/get_name_space', getNamespace)
.get('/getDropSQL', getDropSQL)
.post('/db_sync', bodyParser(), dbSync)
.post('/tke', bodyParser(), dbSyncTke)
.post('/db_sync_query', bodyParser(), dbSyncQuery)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment