From 4df5a628def7b7607e864a511204731e74c307b4 Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Sat, 20 Sep 2025 23:09:39 +0200 Subject: [PATCH] Fix jwt-token --- server/scripts/setup-database.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/scripts/setup-database.js b/server/scripts/setup-database.js index 3989de2..301901a 100644 --- a/server/scripts/setup-database.js +++ b/server/scripts/setup-database.js @@ -1,4 +1,10 @@ -const { Sequelize } = require('sequelize'); +const { Sequelize } = re // Models are already initialized through the imports + console.log('📋 Models loaded and ready...'); + + // For fresh database, just sync to create tables first + console.log('🏗️ Creating database tables...'); + await sequelize.sync({ force: true }); // WARNING: This will drop existing tables + console.log('✅ Database tables created successfully.\n');sequelize'); const bcrypt = require('bcryptjs'); // Import models from the main models index @@ -38,7 +44,7 @@ const setupDatabase = async () => { const adminUser = await User.create({ username: 'admin', email: 'admin@example.com', - password: await bcrypt.hash('admin123', 10), + password_hash: await bcrypt.hash('admin123', 10), role: 'admin' }); console.log(`✅ Admin user created: ${adminUser.username}`); @@ -48,7 +54,7 @@ const setupDatabase = async () => { const operatorUser = await User.create({ username: 'operator', email: 'operator@example.com', - password: await bcrypt.hash('operator123', 10), + password_hash: await bcrypt.hash('operator123', 10), role: 'operator' }); console.log(`✅ Operator user created: ${operatorUser.username}`);