-- OTD140 LAN IP Manager schema
-- MySQL/MariaDB

CREATE DATABASE IF NOT EXISTS otd_manager CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE otd_manager;

CREATE TABLE IF NOT EXISTS device_actions (
  id INT AUTO_INCREMENT PRIMARY KEY,
  device_id INT NOT NULL,
  action ENUM('fetch','change','revert') NOT NULL,
  ok TINYINT(1) NOT NULL DEFAULT 0,
  http_code INT NULL,
  message VARCHAR(255) NULL,
  request_json MEDIUMTEXT NULL,
  response_raw MEDIUMTEXT NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (device_id) REFERENCES devices(id) ON DELETE CASCADE
) ENGINE=InnoDB;
