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