diff --git a/database.js b/database.js index bd02044..d2e1844 100644 --- a/database.js +++ b/database.js @@ -50,6 +50,20 @@ const initDatabase = async () => { ) `); + // Migration: ajouter la colonne lastConnection si elle n'existe pas + await connection.execute(` + PRAGMA table_info(user_links) + `); + + const [columns] = await connection.execute(`PRAGMA table_info(user_links)`); + + const hasLastConnection = columns.some(col => col.name === 'lastConnection'); + + if (!hasLastConnection) { + await connection.execute(`ALTER TABLE user_links ADD COLUMN lastConnection TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP`); + console.log('✅ Colonne lastConnection ajoutée'); + } + console.log('✅ Tables créées/vérifiées'); } catch (error) { console.error('❌ Erreur de connexion à la base de données:', error);