Compare commits

...

2 Commits

3 changed files with 31 additions and 1 deletions

26
convertDatabase.js Normal file
View File

@ -0,0 +1,26 @@
const { Sequelize, DataTypes } = require('sequelize');
require('./dbObjects.js');
const { sequelize, BeatenGames } = require ('./dbObjects.js');
// Add a new column to the existing table
(async () => {
try {
await sequelize.sync();
await sequelize.getQueryInterface().addColumn(
'BeatenGames',
'status',
{
type: DataTypes.ENUM('planning', 'playing', 'beat'),
allowNull: false,
defaultValue: 'beat',
},
);
console.log('New column added successfully');
} catch (error) {
console.error('Error adding new column:', error);
} finally {
sequelize.sync();
}
})();

View File

@ -44,4 +44,4 @@ sequelize.sync({ alter: true })
console.log(err);
});
module.exports = { Users, Games, BeatenGames };
module.exports = { sequelize, Users, Games, BeatenGames };

View File

@ -1,5 +1,9 @@
module.exports = (sequelize, DataTypes) => {
return sequelize.define('beatenGames', {
status: {
type: DataTypes.ENUM('planning', 'playing', 'beat'),
allowNull: true,
},
}, {
timestamps: true,
});