From c8c6f5a080c5f47109813c90b0897dec35a0b645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Thu, 5 Mar 2026 16:38:44 -0300 Subject: [PATCH] fix: auto-create auth tables on startup to bypass docker swarm config caching --- backend/index.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/backend/index.js b/backend/index.js index c227afb..b3ddc82 100644 --- a/backend/index.js +++ b/backend/index.js @@ -616,6 +616,32 @@ const provisionSuperAdmin = async (retries = 10, delay = 10000) => { try { // Test connection first const connection = await pool.getConnection(); + + // Auto-create missing tables to prevent issues with outdated Docker configs/volumes + await connection.query(` + CREATE TABLE IF NOT EXISTS password_resets ( + email varchar(255) NOT NULL, + token varchar(255) NOT NULL, + expires_at timestamp NOT NULL, + created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (token), + KEY email (email) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + `); + + await connection.query(` + CREATE TABLE IF NOT EXISTS pending_registrations ( + email varchar(255) NOT NULL, + password_hash varchar(255) NOT NULL, + full_name varchar(255) NOT NULL, + organization_name varchar(255) NOT NULL, + verification_code varchar(10) NOT NULL, + expires_at timestamp NOT NULL, + created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (email) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + `); + connection.release(); // Ensure system tenant exists