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