-- ============================================================
-- Schema tabelle – esameits24-26
-- Allineato alle API: /utenti, 
-- ============================================================

USE `esameits24-26`;

-- ------------------------------------------------------------
-- Tabella utenti  (API: GET/POST/PUT/DELETE /utenti)
-- ------------------------------------------------------------
CREATE TABLE IF NOT EXISTS utenti (
  UtenteID   INT UNSIGNED  NOT NULL AUTO_INCREMENT,
  Nome          VARCHAR(100)  NOT NULL,
  Cognome       VARCHAR(100)  NOT NULL,
  Email         VARCHAR(255)  NOT NULL,
  PasswordHash  VARCHAR(255)  NOT NULL COMMENT 'Password salvata come hash (es. bcrypt)',
  Admin         BOOLEAN       NOT NULL DEFAULT FALSE,
  created_at    DATETIME      NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at    DATETIME      NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

  PRIMARY KEY (UtenteID),
  UNIQUE KEY uk_utente_email (Email)
) ENGINE=InnoDB
  DEFAULT CHARSET=utf8mb4
  COLLATE=utf8mb4_unicode_ci;


