TheOchulus/dbInit.js

21 lines
655 B
JavaScript
Raw Normal View History

2023-12-16 21:38:58 +01:00
const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'username', 'password', {
host: 'localhost',
dialect: 'sqlite',
logging: false,
storage: 'database.sqlite',
});
const db = require('./models/games.js')(sequelize, Sequelize.DataTypes);
require('./models/users.js')(sequelize, Sequelize.DataTypes);
2023-12-18 22:55:20 +01:00
require('./models/beatenGames.js')(sequelize, Sequelize.DataTypes);
2023-12-16 21:38:58 +01:00
const force = process.argv.includes('--force') || process.argv.includes('-f');
sequelize.sync({ force }).then(async () => {
// await Promise.all();
console.log('Database synced');
sequelize.close();
}).catch(console.error);