Create dbInit

This commit is contained in:
baz 2023-12-16 20:38:58 +00:00
parent 1519c85f27
commit e2d3881cce
1 changed files with 20 additions and 0 deletions

20
dbInit.js Normal file
View File

@ -0,0 +1,20 @@
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);
require('models/beatenGames.js')(sequelize, Sequelize.DataTypes);
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);