Gestion des utilisateurs
This commit is contained in:
@@ -1800,4 +1800,26 @@ db.exec('CREATE INDEX IF NOT EXISTS idx_2fa_dev_uid ON two_fa_trusted_devices(
|
||||
|
||||
console.log('[DB] Migrations 2FA OK');
|
||||
|
||||
// ── Table invitations ────────────────────────────────────────────────────────
|
||||
{
|
||||
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='invitations'").get();
|
||||
if (!tables) {
|
||||
db.exec(`
|
||||
CREATE TABLE invitations (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
token TEXT NOT NULL UNIQUE,
|
||||
email TEXT NOT NULL,
|
||||
role TEXT NOT NULL DEFAULT 'user',
|
||||
invited_by INTEGER REFERENCES users(id) ON DELETE SET NULL,
|
||||
expires_at TEXT NOT NULL,
|
||||
used_at TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
)
|
||||
`);
|
||||
db.exec('CREATE INDEX IF NOT EXISTS idx_invitations_token ON invitations(token)');
|
||||
console.log('[DB] Table invitations créée');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default db;
|
||||
|
||||
Reference in New Issue
Block a user