CREATE TABLE IF NOT EXISTS matches (
  id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  match_date DATE NOT NULL,
  match_time TIME NULL,
  team VARCHAR(120) NOT NULL,
  opponent VARCHAR(120) DEFAULT NULL,
  venue VARCHAR(150) DEFAULT NULL,
  competition VARCHAR(150) DEFAULT NULL,
  note TEXT DEFAULT NULL,
  row_hash CHAR(64) NOT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  UNIQUE KEY uniq_row (row_hash),
  KEY idx_date (match_date),
  KEY idx_team (team),
  KEY idx_venue (venue)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS locker_rules (
  id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  venue VARCHAR(150) NOT NULL,
  lockers INT NOT NULL DEFAULT 8,
  UNIQUE KEY uniq_venue (venue)
);
