CREATE DATABASE e_agreement_html CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

USE e_agreement_html;

CREATE TABLE agreements (
  id INT AUTO_INCREMENT PRIMARY KEY,
  token VARCHAR(32) UNIQUE NOT NULL,
  status ENUM('awaiting_hirer','ready_for_signature','signed') DEFAULT 'awaiting_hirer',
  vehicle_json LONGTEXT NOT NULL,
  hirer_json LONGTEXT NULL,
  signature_data MEDIUMTEXT NULL,
  pdf_path VARCHAR(255) NULL,
  signed_at DATETIME NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
