X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=scripts%2Fdanger%2Fclean%2Fcleaner.js;h=d1e2181452d23bae25e515446a38a7c83f95d941;hb=dd6019932efd6ae3b790bf024bc0cd74162e4517;hp=10e91e7000d1965996b0dc4edcde861c2a58dff2;hpb=8c67719c80cef7319afecdf1078d5447149ad8e7;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/danger/clean/cleaner.js b/scripts/danger/clean/cleaner.js index 10e91e700..d1e218145 100644 --- a/scripts/danger/clean/cleaner.js +++ b/scripts/danger/clean/cleaner.js @@ -1,24 +1,23 @@ const rimraf = require('rimraf') -const mongoose = require('mongoose') -mongoose.Promise = global.Promise const constants = require('../../../server/initializers/constants') +const db = require('../../../server/initializers/database') -const mongodbUrl = 'mongodb://' + constants.CONFIG.DATABASE.HOSTNAME + ':' + constants.CONFIG.DATABASE.PORT + '/' + constants.CONFIG.DATABASE.DBNAME -mongoose.connect(mongodbUrl, function () { - console.info('Deleting MongoDB %s database.', constants.CONFIG.DATABASE.DBNAME) - mongoose.connection.dropDatabase(function () { - mongoose.connection.close() - }) -}) +db.init(true, function () { + db.sequelize.drop().asCallback(function (err) { + if (err) throw err -const STORAGE = constants.CONFIG.STORAGE -Object.keys(STORAGE).forEach(function (storage) { - const storageDir = STORAGE[storage] + console.info('Tables of %s deleted.', db.sequelize.config.database) - rimraf(storageDir, function (err) { - if (err) throw err + const STORAGE = constants.CONFIG.STORAGE + Object.keys(STORAGE).forEach(function (storage) { + const storageDir = STORAGE[storage] + + rimraf(storageDir, function (err) { + if (err) throw err - console.info('Deleting %s.', storageDir) + console.info('Deleting %s.', storageDir) + }) + }) }) })