let Promise = require('bluebird')

let model = require('../connect')

let upload = function (id, table, path, field) {
  return new Promise((resolve, reject) => {
    model.knex(table + id).del().then(() => {
      let query = 'truncate ' + table + id
      return model.knex.raw(query)
    }).then(() => {
      let query = 'load data local infile \'' + path + '\' into table ' + table + id + ' (' + field + ')'
      return model.knex.raw(query)
    }).then(() => {
      resolve()
    }).catch(error => {
      console.log(error)
      reject()
    })
  })
}

module.exports = {
  upload: upload
}
@@ -225,15 +225,18 @@
  = '
-truncat
+alter tabl
 e ' 
@@ -247,16 +247,40 @@
 ble + id
+ + ' AUTO_INCREMENT = 1'
 %0A      r

modify SQL query