RIP Database again

This commit is contained in:
Daniel Odendahl Jr
2017-10-01 22:50:28 +00:00
parent 2068122e11
commit 4f5c6bd643
5 changed files with 7 additions and 290 deletions
-26
View File
@@ -1,26 +0,0 @@
const Sequelize = require('sequelize');
const { DB_URL } = process.env;
const database = new Sequelize(DB_URL, { logging: false });
class Database {
static get db() {
return database;
}
static start() {
database.authenticate()
.then(() => console.log('[DATABASE] Connection established successfully.'))
.then(() => console.log('[DATABASE] Synchronizing...'))
.then(() => database.sync()
.then(() => console.log('[DATABASE] Done Synchronizing!'))
.catch(err => console.error(`[DATABASE] Error synchronizing: ${err}`))
)
.catch(err => {
console.error(`[DATABASE] Unable to connect: ${err}`);
console.error('[DATABASE] Reconnecting in 5 seconds...');
setTimeout(() => Database.start(), 5000);
});
}
}
module.exports = Database;