Fix jwt-token

This commit is contained in:
2025-09-17 06:35:58 +02:00
parent 7cc24c0a5d
commit c8874a30ed

View File

@@ -2,30 +2,48 @@
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
// Check if raw_payload column exists in drone_detections before adding try {
const droneDetectionsTable = await queryInterface.describeTable('drone_detections'); // Check if tables exist first
if (!droneDetectionsTable.raw_payload) { const tables = await queryInterface.showAllTables();
await queryInterface.addColumn('drone_detections', 'raw_payload', {
type: Sequelize.JSON, // Handle drone_detections table
allowNull: true, if (!tables.includes('drone_detections')) {
comment: 'Complete raw payload received from detector (for debugging)' console.log('⚠️ drone_detections table does not exist yet, skipping raw_payload migration for this table...');
}); } else {
console.log('✅ Added raw_payload field to drone_detections table'); // Check if raw_payload column exists in drone_detections before adding
} else { const droneDetectionsTable = await queryInterface.describeTable('drone_detections');
console.log('⏭️ raw_payload field already exists in drone_detections table'); if (!droneDetectionsTable.raw_payload) {
} await queryInterface.addColumn('drone_detections', 'raw_payload', {
type: Sequelize.JSON,
allowNull: true,
comment: 'Complete raw payload received from detector (for debugging)'
});
console.log('✅ Added raw_payload field to drone_detections table');
} else {
console.log('⏭️ raw_payload field already exists in drone_detections table');
}
}
// Check if raw_payload column exists in heartbeats before adding // Handle heartbeats table
const heartbeatsTable = await queryInterface.describeTable('heartbeats'); if (!tables.includes('heartbeats')) {
if (!heartbeatsTable.raw_payload) { console.log('⚠️ heartbeats table does not exist yet, skipping raw_payload migration for this table...');
await queryInterface.addColumn('heartbeats', 'raw_payload', { } else {
type: Sequelize.JSON, // Check if raw_payload column exists in heartbeats before adding
allowNull: true, const heartbeatsTable = await queryInterface.describeTable('heartbeats');
comment: 'Complete raw payload received from detector (for debugging)' if (!heartbeatsTable.raw_payload) {
}); await queryInterface.addColumn('heartbeats', 'raw_payload', {
console.log('✅ Added raw_payload field to heartbeats table'); type: Sequelize.JSON,
} else { allowNull: true,
console.log('⏭️ raw_payload field already exists in heartbeats table'); comment: 'Complete raw payload received from detector (for debugging)'
});
console.log('✅ Added raw_payload field to heartbeats table');
} else {
console.log('⏭️ raw_payload field already exists in heartbeats table');
}
}
} catch (error) {
console.log('⚠️ Migration skipped - tables may not exist yet:', error.message);
// Don't throw error, just skip this migration if tables don't exist
} }
}, },