2017-07-05 07:26:25 -04:00
|
|
|
import * as Promise from 'bluebird'
|
2017-12-12 11:53:50 -05:00
|
|
|
import * as rimraf from 'rimraf'
|
2017-12-13 11:46:23 -05:00
|
|
|
import { CONFIG, initDatabaseModels, sequelizeTypescript } from '../../../server/initializers'
|
2016-10-13 15:45:23 -04:00
|
|
|
|
2017-12-13 11:46:23 -05:00
|
|
|
initDatabaseModels(true)
|
2017-07-05 07:26:25 -04:00
|
|
|
.then(() => {
|
2017-12-12 11:53:50 -05:00
|
|
|
return sequelizeTypescript.drop()
|
2017-07-05 07:26:25 -04:00
|
|
|
})
|
|
|
|
.then(() => {
|
2017-06-11 09:19:43 -04:00
|
|
|
console.info('Tables of %s deleted.', CONFIG.DATABASE.DBNAME)
|
2016-10-13 15:45:23 -04:00
|
|
|
|
2017-06-11 09:19:43 -04:00
|
|
|
const STORAGE = CONFIG.STORAGE
|
2017-07-05 07:26:25 -04:00
|
|
|
Promise.mapSeries(Object.keys(STORAGE), storage => {
|
2016-12-25 03:44:13 -05:00
|
|
|
const storageDir = STORAGE[storage]
|
|
|
|
|
2017-07-05 07:26:25 -04:00
|
|
|
return new Promise((res, rej) => {
|
2017-09-07 09:27:35 -04:00
|
|
|
rimraf(storageDir, err => {
|
2017-07-05 07:26:25 -04:00
|
|
|
if (err) return rej(err)
|
|
|
|
|
|
|
|
console.info('%s deleted.', storageDir)
|
|
|
|
return res()
|
|
|
|
})
|
2016-12-25 03:44:13 -05:00
|
|
|
})
|
|
|
|
})
|
2017-07-05 07:26:25 -04:00
|
|
|
.then(() => process.exit(0))
|
2016-10-13 15:45:23 -04:00
|
|
|
})
|