-- Tabla de definición de campos personalizados
CREATE TABLE IF NOT EXISTS worker_fields (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100) NOT NULL,
  key_name VARCHAR(100) NOT NULL UNIQUE,
  type ENUM('text','number','date','select') NOT NULL,
  section ENUM('basica','laboral') NOT NULL,
  required TINYINT(1) NOT NULL DEFAULT 0,
  options TEXT DEFAULT NULL,
  ordering INT DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Tabla de valores de campos personalizados por trabajador
CREATE TABLE IF NOT EXISTS worker_field_values (
  id INT AUTO_INCREMENT PRIMARY KEY,
  worker_id INT NOT NULL,
  field_id INT NOT NULL,
  value TEXT,
  FOREIGN KEY (worker_id) REFERENCES workers(id) ON DELETE CASCADE,
  FOREIGN KEY (field_id) REFERENCES worker_fields(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 