-- DHCPMan v0.9 — Migration : demandes de réservation publiques
-- À exécuter sur une installation existante (v0.8 → v0.9)

ALTER TABLE app_subnets
    ADD COLUMN is_public TINYINT(1) NOT NULL DEFAULT 0
        COMMENT '1 = visible dans le formulaire de demande public';

CREATE TABLE IF NOT EXISTS app_reservation_requests (
    id               INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    requester_name   VARCHAR(100) NOT NULL,
    requester_email  VARCHAR(150) NOT NULL,
    mac_address      VARCHAR(17)  NOT NULL,
    subnet_id        INT UNSIGNED NOT NULL COMMENT 'app_subnets.id',
    description      TEXT         NULL,
    status           ENUM('pending') NOT NULL DEFAULT 'pending',
    created_at       DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_created_at (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
