USE faunamix;

SET @has_status := (
  SELECT COUNT(*) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'reservation_requests'
    AND COLUMN_NAME = 'status'
);
SET @sql_status := IF(
  @has_status = 0,
  "ALTER TABLE reservation_requests ADD COLUMN status ENUM('new','processed','cancelled') NOT NULL DEFAULT 'new' AFTER requested_end",
  'SELECT 1'
);
PREPARE stmt FROM @sql_status; EXECUTE stmt; DEALLOCATE PREPARE stmt;
