-- Klartext-PIN-Spalte für students (Lehrer-vergebene Passwörter sichtbar)
-- IF NOT EXISTS-äquivalent über Information_Schema-Check
SET @col_exists = (
  SELECT COUNT(*) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'students' AND COLUMN_NAME = 'password_plaintext'
);
SET @sql = IF(@col_exists = 0,
  'ALTER TABLE students ADD COLUMN password_plaintext VARCHAR(64) NULL AFTER password',
  'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
