execute(<<query('SELECT user_id, user_totp_key FROM msz_users WHERE user_totp_key IS NOT NULL'); $stmt = $conn->prepare('INSERT INTO msz_users_totp (user_id, totp_secret) VALUES (?, ?)'); while($result->next()) { $stmt->addParameter(1, $result->getString(0)); $stmt->addParameter(2, Base32::decode($result->getString(1))); $stmt->execute(); } $conn->execute('ALTER TABLE msz_users DROP COLUMN user_totp_key'); } }