esameits24-26backend/initdb/01_schema.sql

30 lines
1.2 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ============================================================
-- Schema tabelle esameits24-26
-- Allineato alle API: /utenti,
-- ============================================================
USE `esameits24-26`;
-- ------------------------------------------------------------
-- Tabella UTENTI
-- Ruoli: DIPENDENTE | RESPONSABILE_AMMINISTRATIVO
-- ------------------------------------------------------------
CREATE TABLE IF NOT EXISTS utenti (
utente_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
nome VARCHAR(100) NOT NULL,
cognome VARCHAR(100) NOT NULL,
email VARCHAR(255) NOT NULL,
password_hash VARCHAR(255) NOT NULL COMMENT 'Password salvata come hash (es. bcrypt)',
ruolo ENUM('DIPENDENTE', 'RESPONSABILE_AMMINISTRATIVO')
NOT NULL DEFAULT 'DIPENDENTE',
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (utente_id),
UNIQUE KEY uk_utenti_email (email),
KEY idx_utenti_ruolo (ruolo)
) ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_unicode_ci;