-- API sessions for app login: token_hash, user_id, expires_at.
-- Validated in auth; used to link access_requests to user.

CREATE TABLE IF NOT EXISTS api_sessions (
  token_hash VARCHAR(64) NOT NULL PRIMARY KEY,
  user_id INT UNSIGNED NOT NULL,
  expires_at DATETIME NOT NULL,
  created_at DATETIME NOT NULL,
  INDEX idx_api_sessions_user (user_id),
  INDEX idx_api_sessions_expires (expires_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS ftt_api_sessions (
  token_hash VARCHAR(64) NOT NULL PRIMARY KEY,
  user_id INT UNSIGNED NOT NULL,
  expires_at DATETIME NOT NULL,
  created_at DATETIME NOT NULL,
  INDEX idx_ftt_api_sessions_user (user_id),
  INDEX idx_ftt_api_sessions_expires (expires_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
