Fix jwt-token
This commit is contained in:
@@ -18,6 +18,7 @@ const seedDatabase = require('./seedDatabase');
|
||||
const errorHandler = require('./middleware/errorHandler');
|
||||
const { apiDebugMiddleware } = require('./utils/apiDebugLogger');
|
||||
const IPRestrictionMiddleware = require('./middleware/ip-restriction');
|
||||
const { Umzug, SequelizeStorage } = require('umzug');
|
||||
|
||||
const app = express();
|
||||
|
||||
@@ -121,12 +122,36 @@ initializeSocketHandlers(io);
|
||||
|
||||
const PORT = process.env.PORT || 3001;
|
||||
|
||||
// Migration runner
|
||||
const runMigrations = async () => {
|
||||
const umzug = new Umzug({
|
||||
migrations: {
|
||||
glob: 'migrations/*.js',
|
||||
},
|
||||
context: sequelize.getQueryInterface(),
|
||||
storage: new SequelizeStorage({ sequelize }),
|
||||
logger: console,
|
||||
});
|
||||
|
||||
console.log('Running database migrations...');
|
||||
await umzug.up();
|
||||
console.log('Migrations completed successfully.');
|
||||
};
|
||||
|
||||
// Database connection and server startup
|
||||
async function startServer() {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Database connected successfully.');
|
||||
|
||||
// Run migrations first
|
||||
try {
|
||||
await runMigrations();
|
||||
} catch (migrationError) {
|
||||
console.error('Migration error:', migrationError);
|
||||
console.log('Continuing with database sync...');
|
||||
}
|
||||
|
||||
// Always sync database in containerized environments or development
|
||||
// Check if tables exist before syncing
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user