Compare commits
	
		
			2 Commits
		
	
	
		
			152a2c2fd1
			...
			d2893d6d2e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| d2893d6d2e | |||
| 62af00b8d0 | 
							
								
								
									
										26
									
								
								convertDatabase.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								convertDatabase.js
									
									
									
									
									
										Normal 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();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					})();
 | 
				
			||||||
@ -44,4 +44,4 @@ sequelize.sync({ alter: true })
 | 
				
			|||||||
    console.log(err);
 | 
					    console.log(err);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = { Users, Games, BeatenGames };
 | 
					module.exports = { sequelize, Users, Games, BeatenGames };
 | 
				
			||||||
@ -1,5 +1,9 @@
 | 
				
			|||||||
module.exports = (sequelize, DataTypes) => {
 | 
					module.exports = (sequelize, DataTypes) => {
 | 
				
			||||||
    return sequelize.define('beatenGames', {
 | 
					    return sequelize.define('beatenGames', {
 | 
				
			||||||
 | 
					        status: {
 | 
				
			||||||
 | 
					            type: DataTypes.ENUM('planning', 'playing', 'beat'),
 | 
				
			||||||
 | 
					            allowNull: true,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
    }, {
 | 
					    }, {
 | 
				
			||||||
        timestamps: true,
 | 
					        timestamps: true,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user