-- +goose Up
CREATE TABLE IF NOT EXISTS helicopter_usage (
  id BINARY(16) NOT NULL,
  helicopter_id BINARY(16) NOT NULL,
  total_landing INT NOT NULL DEFAULT 0,
  total_airframe_hours DECIMAL(12,2) NOT NULL DEFAULT 0,
  total_airframe_cycles INT NOT NULL DEFAULT 0,
  total_engine_1_hours DECIMAL(12,2) NOT NULL DEFAULT 0,
  total_engine_1_gpc_ng_n1 DECIMAL(12,2) NOT NULL DEFAULT 0,
  total_engine_1_ptc_nf_n2 DECIMAL(12,2) NOT NULL DEFAULT 0,
  total_engine_1_ccc INT NOT NULL DEFAULT 0,
  total_engine_2_hours DECIMAL(12,2) NOT NULL DEFAULT 0,
  total_engine_2_gpc_ng_n1 DECIMAL(12,2) NOT NULL DEFAULT 0,
  total_engine_2_ptc_nf_n2 DECIMAL(12,2) NOT NULL DEFAULT 0,
  total_engine_2_ccc INT NOT NULL DEFAULT 0,
  total_flight_report INT NOT NULL DEFAULT 0,
  total_hook_release INT NOT NULL DEFAULT 0,
  total_rotor_brake_cycle INT NOT NULL DEFAULT 0,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  created_by BINARY(16) NULL,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  updated_by BINARY(16) NULL,
  deleted_at DATETIME NULL,
  deleted_by BINARY(16) NULL,
  PRIMARY KEY (id),
  UNIQUE KEY uidx_helicopter_usage_helicopter_id (helicopter_id),
  KEY idx_helicopter_usage_deleted_at (deleted_at),
  CONSTRAINT fk_helicopter_usage_helicopter FOREIGN KEY (helicopter_id) REFERENCES helicopters (id) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- +goose Down
DROP TABLE IF EXISTS helicopter_usage;
